From: Lai Jiangshan Date: Thu, 22 May 2014 00:44:08 +0000 (+1000) Subject: idr: fix idr_replace()'s returned error code X-Git-Tag: next-20140530~2^2~50 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d2bc568820c8937c7e3a3f817626cbc9baa6b9b8;p=karo-tx-linux.git 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 Acked-by: Tejun Heo Signed-off-by: Andrew Morton --- diff --git a/lib/idr.c b/lib/idr.c index 36ff732fd2a6..e79e051bddc1 100644 --- 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) {