Skip to content

Commit

Permalink
idr: fix idr_replace()'s returned error code
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Lai Jiangshan authored and torvalds committed Jun 6, 2014
1 parent aef0f62 commit b93804b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/idr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b93804b

Please sign in to comment.