diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2014-06-06 17:37:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-06 19:08:12 -0400 |
commit | b93804b2fcdb35cc45f95ad77cbe23cc620f6593 (patch) | |
tree | bd4b620b05e1f2ee7990f7080cc2a8b246f33c23 /lib/idr.c | |
parent | aef0f62e87122c0fb90d5da660fd131acd0a9d67 (diff) |
idr: fix idr_replace()'s returned error code
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>
Diffstat (limited to 'lib/idr.c')
-rw-r--r-- | lib/idr.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -814,10 +814,10 @@ void *idr_replace(struct idr *idp, void *ptr, int id) | |||
814 | 814 | ||
815 | p = idp->top; | 815 | p = idp->top; |
816 | if (!p) | 816 | if (!p) |
817 | return ERR_PTR(-EINVAL); | 817 | return ERR_PTR(-ENOENT); |
818 | 818 | ||
819 | if (id > idr_max(p->layer + 1)) | 819 | if (id > idr_max(p->layer + 1)) |
820 | return ERR_PTR(-EINVAL); | 820 | return ERR_PTR(-ENOENT); |
821 | 821 | ||
822 | n = p->layer * IDR_BITS; | 822 | n = p->layer * IDR_BITS; |
823 | while ((n > 0) && p) { | 823 | while ((n > 0) && p) { |