Re: [PATCH 1/4] idr: proper invalid argument handling

From: Andrew Morton
Date: Tue Apr 22 2014 - 15:17:05 EST


On Tue, 22 Apr 2014 18:16:18 +0800 Lai Jiangshan <laijs@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/