netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: chas williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	rusty@rustcorp.com.au, bfields@fieldses.org,
	skinsbursky@parallels.com, ebiederm@xmission.com,
	jmorris@namei.org, axboe@kernel.dk, netdev@vger.kernel.org
Subject: Re: [PATCH 09/62] atm/nicstar: convert to idr_alloc()
Date: Mon, 4 Feb 2013 09:06:24 -0800	[thread overview]
Message-ID: <20130204170624.GJ27963@mtj.dyndns.org> (raw)
In-Reply-To: <20130204090410.2942f8cc@thirdoffive.cmf.nrl.navy.mil>

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

  reply	other threads:[~2013-02-04 17:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1359854463-2538-1-git-send-email-tj@kernel.org>
2013-02-03  1:20 ` [PATCH 09/62] atm/nicstar: convert to idr_alloc() Tejun Heo
2013-02-04 14:04   ` chas williams - CONTRACTOR
2013-02-04 17:06     ` Tejun Heo [this message]
2013-02-04 18:06       ` chas williams - CONTRACTOR
2013-02-04 18:37   ` [PATCH v3 " Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130204170624.GJ27963@mtj.dyndns.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=bfields@fieldses.org \
    --cc=chas@cmf.nrl.navy.mil \
    --cc=ebiederm@xmission.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=skinsbursky@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).