From 9ca3766abf350221e84d2448ea6339b57db0399a Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 27 Feb 2013 17:05:10 -0800 Subject: [PATCH] --- yaml --- r: 359387 b: refs/heads/master c: 7175c61cc6b8e701441e79ef048c11ae97293463 h: refs/heads/master i: 359385: ba52d9af55ea658a43ea5b110442997bbf9d3e13 359383: 7e24e06b264cd103db316d17f1af0eb78bb1ea02 v: v3 --- [refs] | 2 +- trunk/lib/idr.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index b2ee25f646b3..6c97f9f6d51f 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0ffc2a9c8072969253a20821c2c733a2cbb4c7c7 +refs/heads/master: 7175c61cc6b8e701441e79ef048c11ae97293463 diff --git a/trunk/lib/idr.c b/trunk/lib/idr.c index 1a30272066c6..73f4d53c02f3 100644 --- a/trunk/lib/idr.c +++ b/trunk/lib/idr.c @@ -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; @@ -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; @@ -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);