Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359387
b: refs/heads/master
c: 7175c61
h: refs/heads/master
i:
  359385: ba52d9a
  359383: 7e24e06
v: v3
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Feb 28, 2013
1 parent 4b39f5c commit 9ca3766
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0ffc2a9c8072969253a20821c2c733a2cbb4c7c7
refs/heads/master: 7175c61cc6b8e701441e79ef048c11ae97293463
10 changes: 10 additions & 0 deletions trunk/lib/idr.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ void idr_remove(struct idr *idp, int id)
struct idr_layer *p;
struct idr_layer *to_free;

/* see comment in idr_find_slowpath() */
if (WARN_ON_ONCE(id < 0))
return;

Expand Down Expand Up @@ -666,6 +667,14 @@ void *idr_find_slowpath(struct idr *idp, int id)
int n;
struct idr_layer *p;

/*
* If @id is negative, idr_find() used to ignore the sign bit and
* performed lookup with the rest of bits, which is weird and can
* lead to very obscure bugs. We're now returning NULL for all
* negative IDs but just in case somebody was depending on the sign
* bit being ignored, let's trigger WARN_ON_ONCE() so that they can
* be detected and fixed. WARN_ON_ONCE() can later be removed.
*/
if (WARN_ON_ONCE(id < 0))
return NULL;

Expand Down Expand Up @@ -815,6 +824,7 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
int n;
struct idr_layer *p, *old_p;

/* see comment in idr_find_slowpath() */
if (WARN_ON_ONCE(id < 0))
return ERR_PTR(-EINVAL);

Expand Down

0 comments on commit 9ca3766

Please sign in to comment.