diff mbox

mpathpersist:check variable 'conf' before using it

Message ID 1478143935-5564-1-git-send-email-tang.wenji@zte.com.cn (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show

Commit Message

tang.wenji@zte.com.cn Nov. 3, 2016, 3:32 a.m. UTC
From: "tang.wenji" <tang.wenji@zte.com.cn>

If the variable 'conf' is NULL, the program should exit.

Signed-off-by: tang.wenji <tang.wenji@zte.com.cn>
---
 mpathpersist/main.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/mpathpersist/main.c b/mpathpersist/main.c
index 8e8cc35..5863082 100644
--- a/mpathpersist/main.c
+++ b/mpathpersist/main.c
@@ -105,6 +105,11 @@  int main (int argc, char * argv[])
 
 	udev = udev_new();
 	conf = mpath_lib_init(udev);
+	if(!conf) {
+		udev_unref(udev);
+		exit(1);
+	}
+	
 	memset(transportids, 0, MPATH_MX_TIDS * sizeof(struct transportid));
 	multipath_conf = conf;