提交 b93804b2 编写于 作者: L Lai Jiangshan 提交者: Linus Torvalds

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: NLai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: NTejun Heo <tj@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 aef0f62e
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册