Chris Leech
2016-10-20 20:56:43 UTC
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 <***@redhat.com>
---
fcoeadm_display.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fcoeadm_display.c b/fcoeadm_display.c
index 7b95aa4..bf3831a 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;
}
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 <***@redhat.com>
---
fcoeadm_display.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fcoeadm_display.c b/fcoeadm_display.c
index 7b95aa4..bf3831a 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.7.4
2.7.4