All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: linux-sparse@vger.kernel.org
Subject: [PATCH] ptrlist: reading deleted items in NEXT_PTR_LIST()
Date: Thu, 23 Jul 2015 11:24:14 +0300	[thread overview]
Message-ID: <20150723082414.GA30778@mwanda> (raw)

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@oracle.com>
---
 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


                 reply	other threads:[~2015-07-23  8:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150723082414.GA30778@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.