idr: fix idr_replace()'s returned error code
authorLai Jiangshan <laijs@cn.fujitsu.com>
Fri, 6 Jun 2014 21:37:13 +0000 (14:37 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 6 Jun 2014 23:08:12 +0000 (16:08 -0700)
When the smaller id is not found, idr_replace() returns -ENOENT.  But
when the id is bigger enough, idr_replace() returns -EINVAL, actually
there is no difference between these two kinds of ids.

These are all unallocated id, the return values of the idr_replace() for
these ids should be the same: -ENOENT.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/idr.c

index 36ff732fd2a6dca0847373d7b3a45048c2f0d0f7..e79e051bddc10d448e083e3422618c4980e5cb02 100644 (file)
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -814,10 +814,10 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
 
        p = idp->top;
        if (!p)
-               return ERR_PTR(-EINVAL);
+               return ERR_PTR(-ENOENT);
 
        if (id > idr_max(p->layer + 1))
-               return ERR_PTR(-EINVAL);
+               return ERR_PTR(-ENOENT);
 
        n = p->layer * IDR_BITS;
        while ((n > 0) && p) {