[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20140422121656.14d5e5534ae4888119787471@linux-foundation.org>
Date: Tue, 22 Apr 2014 12:16:56 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Lai Jiangshan <laijs@...fujitsu.com>
Cc: <linux-kernel@...r.kernel.org>, Tejun Heo <tj@...nel.org>,
Jean Delvare <jdelvare@...e.de>,
Monam Agarwal <monamagarwal123@...il.com>,
Jeff Layton <jlayton@...hat.com>,
Andreas Gruenbacher <agruen@...bit.com>,
Stephen Hemminger <stephen@...workplumber.org>
Subject: Re: [PATCH 1/4] idr: proper invalid argument handling
On Tue, 22 Apr 2014 18:16:18 +0800 Lai Jiangshan <laijs@...fujitsu.com> wrote:
> When the arguments passed by the caller are invalid, WARN_ON_ONCE()
> is proper than BUG_ON() which may crash the kernel.
>
> ida_remove()/idr_remove() add checks for "id < 0".
> BUG_ON() in ida_simple_remove() is simply removed, due to
> ida_remove() already checks for "id < 0".
>
> In idr_alloc(), it still returns -ENOSPC when "start == end",
> but it returns -EINVAL when "max < start" while old code returns
> -ENOSPC. -EINVAL is proper here, the caller must passed wrong
> arguments.
>
> ida_simple_get()'s argument-checks are changed as the same as
> idr_alloc().
This patch doesn't apply.
> @@ -551,10 +553,7 @@ void idr_remove(struct idr *idp, int id)
> struct idr_layer *p;
> struct idr_layer *to_free;
>
> - if (id < 0)
> - return;
> -
> - if (id > idr_max(idp->layers)) {
> + if (id < 0 || id > idr_max(idp->layers)) {
> idr_remove_warning(id);
> return;
> }
3.15-rc2's idr_remove() has a call to sub_remove() in there, but
whatever-kernel-you're-using does not.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists