All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] idr: prevent NULL deref on lookups before insertions
@ 2013-02-20 18:44 Sasha Levin
  2013-02-20 18:45 ` Tejun Heo
  0 siblings, 1 reply; 26+ messages in thread
From: Sasha Levin @ 2013-02-20 18:44 UTC (permalink / raw)
  To: tj; +Cc: akpm, linux-kernel, Sasha Levin

'hint' will be NULL if we're looking up before adding anything
to the IDR.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 include/linux/idr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/idr.h b/include/linux/idr.h
index aed2a0c..a6f38b5 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -113,7 +113,7 @@ static inline void *idr_find(struct idr *idr, int id)
 {
 	struct idr_layer *hint = rcu_dereference_raw(idr->hint);
 
-	if ((id & ~IDR_MASK) == hint->prefix)
+	if (hint && (id & ~IDR_MASK) == hint->prefix)
 		return rcu_dereference_raw(hint->ary[id & IDR_MASK]);
 
 	return idr_find_slowpath(idr, id);
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-02-21 16:39 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-20 18:44 [PATCH] idr: prevent NULL deref on lookups before insertions Sasha Levin
2013-02-20 18:45 ` Tejun Heo
2013-02-20 19:23   ` Sasha Levin
2013-02-20 21:01     ` [PATCH] posix-timer: don't call idr_find() w/ negative ID Tejun Heo
2013-02-20 21:23       ` Andrew Morton
2013-02-20 21:37         ` Tejun Heo
2013-02-20 22:05           ` Andrew Morton
2013-02-20 22:08             ` Tejun Heo
2013-02-20 22:40               ` [PATCH] posix-timer: don't call idr_find() w/ out-of-range ID Tejun Heo
2013-02-20 23:01                 ` Thomas Gleixner
2013-02-20 23:07                   ` Tejun Heo
2013-02-20 23:11                     ` Thomas Gleixner
2013-02-20 23:24                 ` [PATCH UPDATED] " Tejun Heo
2013-02-20 23:35                   ` [PATCH] idr: explain WARN_ON_ONCE() on negative IDs " Tejun Heo
2013-02-21  9:10                     ` Thomas Gleixner
2013-02-21 16:38                   ` [tip:timers/urgent] posix-timer: Don't call idr_find() with " tip-bot for Tejun Heo
2013-02-20 22:10             ` [PATCH] posix-timer: don't call idr_find() w/ negative ID Sasha Levin
2013-02-20 22:12               ` Tejun Heo
2013-02-20 22:15                 ` Sasha Levin
2013-02-20 22:20                   ` Tejun Heo
2013-02-20 23:09             ` Thomas Gleixner
2013-02-20 21:32       ` Sasha Levin
2013-02-20 21:38       ` Thomas Gleixner
2013-02-20 21:43         ` Tejun Heo
2013-02-20 21:47           ` Thomas Gleixner
2013-02-20 21:50             ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.