lkml.org 
[lkml]   [2019]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v12 2/3] ipc: Conserve sequence numbers in ipcmni_extend mode
From
Date
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

\
 
 \ /
  Last update: 2019-03-18 19:58    [W:0.083 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site