Skip to content

Commit 7c657f2

Browse files
John McCutchanLinus Torvalds
authored andcommitted
[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: John McCutchan <ttb@tentacle.dhs.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 755528c commit 7c657f2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/inotify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static int inotify_dev_get_wd(struct inotify_device *dev,
353353
do {
354354
if (unlikely(!idr_pre_get(&dev->idr, GFP_KERNEL)))
355355
return -ENOSPC;
356-
ret = idr_get_new_above(&dev->idr, watch, dev->last_wd, &watch->wd);
356+
ret = idr_get_new_above(&dev->idr, watch, dev->last_wd+1, &watch->wd);
357357
} while (ret == -EAGAIN);
358358

359359
return ret;

lib/idr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id)
207207
}
208208

209209
/**
210-
* idr_get_new_above - allocate new idr entry above a start id
210+
* idr_get_new_above - allocate new idr entry above or equal to a start id
211211
* @idp: idr handle
212212
* @ptr: pointer you want associated with the ide
213213
* @start_id: id to start search at

0 commit comments

Comments
 (0)