Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b93804b2 authored by Lai Jiangshan's avatar Lai Jiangshan Committed by Linus Torvalds
Browse files

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: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent aef0f62e
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -814,10 +814,10 @@ void *idr_replace(struct idr *idp, void *ptr, int id)


	p = idp->top;
	p = idp->top;
	if (!p)
	if (!p)
		return ERR_PTR(-EINVAL);
		return ERR_PTR(-ENOENT);


	if (id > idr_max(p->layer + 1))
	if (id > idr_max(p->layer + 1))
		return ERR_PTR(-EINVAL);
		return ERR_PTR(-ENOENT);


	n = p->layer * IDR_BITS;
	n = p->layer * IDR_BITS;
	while ((n > 0) && p) {
	while ((n > 0) && p) {