Skip to content
Snippets Groups Projects
Commit b9c4b3ca authored by Dinghao Liu's avatar Dinghao Liu Committed by Greg Kroah-Hartman
Browse files

scsi: zfcp: Fix a double put in zfcp_port_enqueue()


commit b481f644 upstream.

When device_register() fails, zfcp_port_release() will be called after
put_device(). As a result, zfcp_ccw_adapter_put() will be called twice: one
in zfcp_port_release() and one in the error path after device_register().
So the reference on the adapter object is doubly put, which may lead to a
premature free. Fix this by adjusting the error tag after
device_register().

Fixes: f3450c7b ("[SCSI] zfcp: Replace local reference counting with common kref")
Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
Link: https://lore.kernel.org/r/20230923103723.10320-1-dinghao.liu@zju.edu.cn


Acked-by: default avatarBenjamin Block <bblock@linux.ibm.com>
Cc: stable@vger.kernel.org # v2.6.33+
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 04b6b67a
No related branches found
No related tags found
2 merge requests!185🤖 Sync Bot: Update v5.10-ktn to Latest Stable Kernel (v5.10.234),!172🤖 Sync Bot: Update v5.10-ktn to Latest Stable Kernel (v5.10.230)
...@@ -497,12 +497,12 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, ...@@ -497,12 +497,12 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
if (port) { if (port) {
put_device(&port->dev); put_device(&port->dev);
retval = -EEXIST; retval = -EEXIST;
goto err_out; goto err_put;
} }
port = kzalloc(sizeof(struct zfcp_port), GFP_KERNEL); port = kzalloc(sizeof(struct zfcp_port), GFP_KERNEL);
if (!port) if (!port)
goto err_out; goto err_put;
rwlock_init(&port->unit_list_lock); rwlock_init(&port->unit_list_lock);
INIT_LIST_HEAD(&port->unit_list); INIT_LIST_HEAD(&port->unit_list);
...@@ -525,7 +525,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, ...@@ -525,7 +525,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
if (dev_set_name(&port->dev, "0x%016llx", (unsigned long long)wwpn)) { if (dev_set_name(&port->dev, "0x%016llx", (unsigned long long)wwpn)) {
kfree(port); kfree(port);
goto err_out; goto err_put;
} }
retval = -EINVAL; retval = -EINVAL;
...@@ -542,7 +542,8 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, ...@@ -542,7 +542,8 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
return port; return port;
err_out: err_put:
zfcp_ccw_adapter_put(adapter); zfcp_ccw_adapter_put(adapter);
err_out:
return ERR_PTR(retval); return ERR_PTR(retval);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment