Linux Device Mapper development
 help / color / mirror / Atom feed
From: michaelc@cs.wisc.edu
To: dm-devel@redhat.com, christophe.varoqui@gmail.com
Subject: [PATCH 1/1] libmultipath: fix segfault when vector is null
Date: Tue,  8 Jan 2013 13:36:34 -0600	[thread overview]
Message-ID: <1357673794-4894-1-git-send-email-michaelc@cs.wisc.edu> (raw)

From: Mike Christie <michaelc@cs.wisc.edu>

While performing tests that caused paths to get added
and deleted, we hit a segfault. We traced it to the
vector struct being NULL. This patch fixes the problem
by checking for a NULL vector before accessing it.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
 libmultipath/vector.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libmultipath/vector.c b/libmultipath/vector.c
index 652f118..0564224 100644
--- a/libmultipath/vector.c
+++ b/libmultipath/vector.c
@@ -94,6 +94,9 @@ find_slot(vector v, void * addr)
 {
 	int i;
 
+	if (!v)
+		return -1;
+
 	for (i = 0; i < (v->allocated / VECTOR_DEFAULT_SIZE); i++)
 		if (v->slot[i] == addr)
 			return i;
-- 
1.7.11.2

             reply	other threads:[~2013-01-08 19:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 19:36 michaelc [this message]
2013-01-08 23:45 ` [PATCH 1/1] libmultipath: fix segfault when vector is null Christophe Varoqui

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=1357673794-4894-1-git-send-email-michaelc@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=christophe.varoqui@gmail.com \
    --cc=dm-devel@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox