提交 7c657f2f 编写于 作者: J John McCutchan 提交者: Linus Torvalds

[PATCH] Document idr_get_new_above() semantics, update inotify

There is an off by one problem with idr_get_new_above.

The comment and function name suggest that it will return an id >
starting_id, but it actually returned an id >= starting_id, and kernel
callers other than inotify treated it as such.

The patch below fixes the comment, and fixes inotifys usage.  The
function name still doesn't match the behaviour, but it never did.
Signed-off-by: NJohn McCutchan <ttb@tentacle.dhs.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 755528c8
......@@ -353,7 +353,7 @@ static int inotify_dev_get_wd(struct inotify_device *dev,
do {
if (unlikely(!idr_pre_get(&dev->idr, GFP_KERNEL)))
return -ENOSPC;
ret = idr_get_new_above(&dev->idr, watch, dev->last_wd, &watch->wd);
ret = idr_get_new_above(&dev->idr, watch, dev->last_wd+1, &watch->wd);
} while (ret == -EAGAIN);
return ret;
......
......@@ -207,7 +207,7 @@ static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id)
}
/**
* idr_get_new_above - allocate new idr entry above a start id
* idr_get_new_above - allocate new idr entry above or equal to a start id
* @idp: idr handle
* @ptr: pointer you want associated with the ide
* @start_id: id to start search at
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册