Re: [PATCH v12 2/3] ipc: Conserve sequence numbers in ipcmni_extend mode

From: Waiman Long
Date: Mon Mar 18 2019 - 14:57:52 EST


On 03/16/2019 02:52 PM, Manfred Spraul wrote:
> Hi,
>
> On 2/28/19 7:47 PM, Waiman Long wrote:
>> @@ -216,10 +221,11 @@ static inline int ipc_idr_alloc(struct ipc_ids
>> *ids, struct kern_ipc_perm *new)
>> ÂÂÂÂÂÂ */
>> Â ÂÂÂÂÂ if (next_id < 0) { /* !CHECKPOINT_RESTORE or next_id is unset */
>> -ÂÂÂÂÂÂÂ new->seq = ids->seq++;
>> -ÂÂÂÂÂÂÂ if (ids->seq > IPCID_SEQ_MAX)
>> -ÂÂÂÂÂÂÂÂÂÂÂ ids->seq = 0;
>> ÂÂÂÂÂÂÂÂÂ idx = idr_alloc(&ids->ipcs_idr, new, 0, 0, GFP_NOWAIT);
>> +ÂÂÂÂÂÂÂ if ((idx <= ids->last_idx) && (++ids->seq > IPCID_SEQ_MAX))
>> +ÂÂÂÂÂÂÂÂÂÂÂ ids->seq = 0;
>
> I'm always impressed by such lines:
>
> Everything in just two lines, use "++a", etc.
>
> But: How did you test it?
>
> idr_alloc() can fail, the code doesn't handle that :-(
>
>

You are right. I should have checked for the error case.

Thanks for spotting that.

Cheers,
Longman