lkml.org 
[lkml]   [2013]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 09/62] atm/nicstar: convert to idr_alloc()
Hello, Chas.

On Mon, Feb 04, 2013 at 09:04:10AM -0500, chas williams - CONTRACTOR wrote:
> I don't quite understand your comment. idr_pre_get() returns 0 in the
> case of failure.

So, if you do the following,

int id1 = 0, id2 = 0;

if (!id1)
err = idr_get_new_above(&card->idr, handle1, 0, &id1);
if (!id2 && err == 0)
err = idr_get_new_above(&card->idr, handle2, 0, &id2);
if (err)
goto out;

You have no way of telling whether id1/2 are allocated or not. 0 is
the special "not allocated" value but it also is a valid ID. The
error path should be freeing id1/2 if either of them has been
allocated but it doesn't and can't with 0 as the non-allocated value.

Thanks.

--
tejun


\
 
 \ /
  Last update: 2013-02-04 18:43    [W:0.095 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site