[PATCH] ptrlist: reading deleted items in NEXT_PTR_LIST()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you call DELETE_CURRENT_PTR(), then you can sometimes end up with a
__list->nr that is zero.  The FOR_EACH_PTR() macro can handle this but
the NEXT_PTR_LIST() macro returns ptr = 0xf0f0f0f0 which leads to a
segfault.

Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
 ptrlist.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ptrlist.h b/ptrlist.h
index 58d3bda..61e159f 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -97,6 +97,8 @@ static inline void *last_ptr_list(struct ptr_list *list)
 			} else {							\
 				__list = __list->next;					\
 				ptr = NULL;						\
+				while (__list->nr == 0 && __list != __head)		\
+					__list = __list->next;				\
 				if (__list != __head) {					\
 					__nr = 0;					\
 					ptr = PTR_ENTRY(__list,0);			\
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux