scsi: zfcp: fix missing zfcp_port reference put on -EBUSY from port_remove [Linux 4.4.181]

scsi: zfcp: fix missing zfcp_port reference put on -EBUSY from port_remove [Linux 4.4.181]

This Linux kernel change "scsi: zfcp: fix missing zfcp_port reference put on -EBUSY from port_remove" is included in the Linux 4.4.181 release. This change is authored by Steffen Maier <maier [at] linux.ibm.com> on Thu May 23 15:23:45 2019 +0200. The commit for this change in Linux stable tree is e85d002 (patch) which is from upstream commit d27e5e0. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream d27e5e0.

scsi: zfcp: fix missing zfcp_port reference put on -EBUSY from port_remove

commit d27e5e07f9c49bf2a6a4ef254ce531c1b4fb5a38 upstream.

With this early return due to zfcp_unit child(ren), we don't use the
zfcp_port reference from the earlier zfcp_get_port_by_wwpn() anymore and
need to put it.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Fixes: d99b601b6338 ("[SCSI] zfcp: restore refcount check on port_remove")
Cc: <stable@vger.kernel.org> #3.7+
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/s390/scsi/zfcp_sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 96a0be1..9ef7efe 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -263,6 +263,7 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
    if (atomic_read(&port->units) > 0) {
        retval = -EBUSY;
        mutex_unlock(&zfcp_sysfs_port_units_mutex);
+       put_device(&port->dev); /* undo zfcp_get_port_by_wwpn() */
        goto out;
    }
    /* port is about to be removed, so no more unit_add */

Leave a Reply

Your email address will not be published. Required fields are marked *