commit b6ca22d980eb67b99ddadbfec8ce83b2ab00522c Author: Brian King Date: Mon May 20 16:04:49 2019 -0500 iprutils: Fix driver unbind on format When formatting a disk from JBOD to RAID, we unbind the disk from the sd driver, including the remote path, in the case of dual adapters, and flush unused multipaths. However, due to a bug, this code wasn't actually working once the SCSI host, bus, or target exceeded a single character. Signed-off-by: Brian King diff --git a/iprlib.c b/iprlib.c index 4d3ab5f..516f069 100644 --- a/iprlib.c +++ b/iprlib.c @@ -10345,7 +10345,8 @@ int ipr_jbod_sysfs_bind(struct ipr_dev *dev, u8 op) char *sysfs_device_name; sysfs_device_name = dev->scsi_dev_data->sysfs_device_name; - size = strnlen(sysfs_device_name, sizeof(sysfs_device_name)); + size = strnlen(sysfs_device_name, + sizeof(dev->scsi_dev_data->sysfs_device_name)); if (op == IPR_JBOD_SYSFS_BIND) { fd = open("/sys/bus/scsi/drivers/sd/bind", O_WRONLY); @@ -10367,7 +10368,8 @@ int ipr_jbod_sysfs_bind(struct ipr_dev *dev, u8 op) mp_dev = find_multipath_jbod(dev); if (mp_dev) { sysfs_device_name = mp_dev->scsi_dev_data->sysfs_device_name; - size = strnlen(sysfs_device_name, sizeof(sysfs_device_name)); + size = strnlen(sysfs_device_name, + sizeof(mp_dev->scsi_dev_data->sysfs_device_name)); rc = write(fd, sysfs_device_name, size); if (rc < 0) { close(fd);