diff mbox

[1/1] libmultipath: fix segfault when vector is null

Message ID 1357673794-4894-1-git-send-email-michaelc@cs.wisc.edu (mailing list archive)
State Deferred, archived
Headers show

Commit Message

Mike Christie Jan. 8, 2013, 7:36 p.m. UTC
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(+)

Comments

Christophe Varoqui Jan. 8, 2013, 11:45 p.m. UTC | #1
On mar., 2013-01-08 at 13:36 -0600, michaelc@cs.wisc.edu wrote:
> 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.
> 
Applied.

Thanks,
Christophe Varoqui
www.opensvc.com

> 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;



--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

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;