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

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

 



From: Mike Christie <michaelc@xxxxxxxxxxx>

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@xxxxxxxxxxx>
---
 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

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


[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux