@@ -1200,6 +1200,7 @@ nvme_sysfs_pathinfo (struct path * pp, vector hwtable)
{
struct udev_device *parent;
const char *attr_path = NULL;
+ const char *attr;
attr_path = udev_device_get_sysname(pp->udev);
if (!attr_path)
@@ -1209,14 +1210,17 @@ nvme_sysfs_pathinfo (struct path * pp, vector hwtable)
&pp->sg_id.host_no,
&pp->sg_id.scsi_id) != 2)
return 1;
- pp->sg_id.channel = 0;
- pp->sg_id.lun = atoi(udev_device_get_sysattr_value(pp->udev, "nsid"));
- parent = udev_device_get_parent(pp->udev);
+ parent = udev_device_get_parent_with_subsystem_devtype(pp->udev,
+ "nvme", NULL);
if (!parent)
return 1;
- pp->sg_id.channel = atoi(udev_device_get_sysattr_value(parent, "cntlid"));
+ attr = udev_device_get_sysattr_value(pp->udev, "nsid");
+ pp->sg_id.lun = attr ? atoi(attr) : 0;
+
+ attr = udev_device_get_sysattr_value(parent, "cntlid");
+ pp->sg_id.channel = attr ? atoi(attr) : 0;
snprintf(pp->vendor_id, SCSI_VENDOR_SIZE, "NVME");
snprintf(pp->product_id, SCSI_PRODUCT_SIZE, "%s",
Such devices have a parent with SUBSYSTEM="nvme-subsystem", not "nvme". Furthermore, avoid a possible segfaults NULL checks. Signed-off-by: Martin Wilck <mwilck@suse.com> --- libmultipath/discovery.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)