Blame SOURCES/fcoe-utils-v1.0.31-9-fcoeadm-target-segfault-with-other-FC-storage-presen.patch

402b2c
From 9b295b18014a8fdc05acf6ceb9343c5c1e2ae716 Mon Sep 17 00:00:00 2001
402b2c
From: Chris Leech <cleech@redhat.com>
402b2c
Date: Thu, 20 Oct 2016 13:56:43 -0700
402b2c
Subject: fcoeadm: --target segfault with other FC storage present
402b2c
402b2c
fcoeadm is segfaulting when trying to parse sysfs paths to rports for
402b2c
traditional FC or non fcoe-utils/libfc FCoE.
402b2c
402b2c
I also changed search_rports to just ignore these instead of returning
402b2c
an error, so that the target information for all fcoe-utils managed
402b2c
storage can be displayed instead of stopping at the first exception.
402b2c
402b2c
Signed-off-by: Chris Leech <cleech@redhat.com>
402b2c
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
402b2c
---
402b2c
 fcoeadm_display.c | 8 +++++---
402b2c
 1 file changed, 5 insertions(+), 3 deletions(-)
402b2c
402b2c
diff --git a/fcoeadm_display.c b/fcoeadm_display.c
402b2c
index 096fe50..120c608 100644
402b2c
--- a/fcoeadm_display.c
402b2c
+++ b/fcoeadm_display.c
402b2c
@@ -660,17 +660,19 @@ static char *get_ifname_from_rport(char *rport)
402b2c
 
402b2c
 	err = asprintf(&path, "%s/%s", "/sys/class/fc_remote_ports", rport);
402b2c
 	if (err == -1)
402b2c
-		return false;
402b2c
+		return NULL;
402b2c
 
402b2c
 	ret = readlink(path, link, sizeof(link));
402b2c
 	free(path);
402b2c
 	if (ret == -1)
402b2c
-		return false;
402b2c
+		return NULL;
402b2c
 
402b2c
 	if (link[ret] != '\0')
402b2c
 		link[ret] = '\0';
402b2c
 
402b2c
 	offs = strstr(link, "/net/");
402b2c
+	if (!offs)
402b2c
+		return NULL;
402b2c
 
402b2c
 	offs = offs + 5;
402b2c
 
402b2c
@@ -778,7 +780,7 @@ static int search_rports(struct dirent *dp, void *arg)
402b2c
 	} else {
402b2c
 		ifname = get_ifname_from_rport(rport);
402b2c
 		if (!ifname)
402b2c
-			return -ENOMEM;
402b2c
+			return 0;
402b2c
 		allocated = true;
402b2c
 	}
402b2c
 
402b2c
-- 
402b2c
2.9.3
402b2c