lkml.org 
[lkml]   [2013]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] idr: prevent NULL deref on lookups before insertions
Date
'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


\
 
 \ /
  Last update: 2013-02-20 20:22    [W:0.109 / U:0.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site