Skip to contentSkip to conversation

Segfault running multipath -d -v 3 at HOL

PATCH Brian Wong 2 participants 2 messages Apr 13, 2006 Device mapper

lore
Share & tools
lore

Brian Wong

author
#0 lore raw

Hi Christophe,

I'm seeing a segfault running multipath -d -v 3 at HOL. Here's the fix for the issue. It might be worth applying similar logic fixes to the rest of the free_x() calls in free_config(); let me know if you want that patch too.

cheers,

brian

libmultipath/config.c +2 -1
index c9d6172..928bfea 100644
@@ -305,7 +305,8 @@ free_config (struct config * conf)
 	free_blacklist_device(conf->blist_device);
 	free_mptable(conf->mptable);
 	free_hwtable(conf->hwtable);
-	free_keywords(conf->keywords);
+	if (conf->keywords)
+		free_keywords(conf->keywords);
 	FREE(conf);
 }
 
libmultipath/parser.c +12 -0
index 385e4fb..bb04968 100644
@@ -18,6 +18,7 @@
  */
 
 #include <syslog.h>
+#include <assert.h>
 
 #include "parser.h"
 #include "memory.h"
@@ -110,6 +111,9 @@ free_keywords(vector keywords)
 	struct keyword *keyword;
 	int i;
 
+	assert(keywords);
+	if (!keywords) return;
+
 	for (i = 0; i < VECTOR_SIZE(keywords); i++) {
 		keyword = VECTOR_SLOT(keywords, i);
 		if (keyword->sub)
@@ -483,3 +487,11 @@ init_data(char *conf_file, void (*init_k
 
 	return r;
 }
+
+/*
+ * Local Variables: ***
+ * mode:c ***
+ * c-basic-offset:8 ***
+ * indent-tabs-mode:1 ***
+ * End: ***
+ */
#1 lore raw
Quoted 7 lines · Brian Wong

Hi Christophe,

I'm seeing a segfault running multipath -d -v 3 at HOL. Here's the fix for the issue. It might be worth applying similar logic fixes to the rest of the free_x() calls in free_config(); let me know if you want that patch too.

Thanks. I applied this bit.

Quoted 24 lines
libmultipath/parser.c +2 -0
index 385e4fb..bb04968 100644
@@ -18,6 +18,7 @@
  */
 
 #include <syslog.h>
 
 #include "parser.h"
 #include "memory.h"
@@ -110,6 +111,9 @@ free_keywords(vector keywords)
 	struct keyword *keyword;
 	int i;
 
+	if (!keywords) return;
+
 	for (i = 0; i < VECTOR_SIZE(keywords); i++) {
 		keyword = VECTOR_SLOT(keywords, i);
 		if (keyword->sub)

libmultipath/parser.c init_data(char *conf_file, void (*init_k · line 489

Quoted 3 lines
libmultipath/parser.c +0 -0
@@ -483,3 +487,11 @@ init_data(char *conf_file, void (*init_k
 
 	return r;
 }

Regards,
cvaroqui