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