lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 22 Sep 2023 15:46:31 +0800
From:   Dinghao Liu <dinghao.liu@....edu.cn>
To:     dinghao.liu@....edu.cn
Cc:     linux-scsi@...r.kernel.org, Steffen Maier <maier@...ux.ibm.com>,
        Benjamin Block <bblock@...ux.ibm.com>,
        Heiko Carstens <hca@...ux.ibm.com>,
        Vasily Gorbik <gor@...ux.ibm.com>,
        Alexander Gordeev <agordeev@...ux.ibm.com>,
        Christian Borntraeger <borntraeger@...ux.ibm.com>,
        Sven Schnelle <svens@...ux.ibm.com>,
        James Bottomley <James.Bottomley@...e.de>,
        Swen Schillig <swen@...t.ibm.com>,
        Christof Schmitt <christof.schmitt@...ibm.com>,
        linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] [v2] scsi: zfcp: Fix a double put in zfcp_port_enqueue

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: f3450c7b9172 ("[SCSI] zfcp: Replace local reference counting with common kref")
Signed-off-by: Dinghao Liu <dinghao.liu@....edu.cn>
---

Changelog:

v2: -Improve the patch description.
    -Add a new label 'err_register' to unify code style.
---
 drivers/s390/scsi/zfcp_aux.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index df782646e856..ad0ef9546501 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -552,7 +552,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
 
 	if (device_register(&port->dev)) {
 		put_device(&port->dev);
-		goto err_out;
+		goto err_register;
 	}
 
 	write_lock_irq(&adapter->port_list_lock);
@@ -565,5 +565,6 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
 
 err_out:
 	zfcp_ccw_adapter_put(adapter);
+err_register:
 	return ERR_PTR(retval);
 }
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ