diff mbox series

scsi: libcxgbi: fix NULL pointer dereference in cxgbi_device_destroy()

Message ID 1576676731-3068-1-git-send-email-varun@chelsio.com (mailing list archive)
State Mainlined
Commit 71482fde704efdd8c3abe0faf34d922c61e8d76b
Headers show
Series scsi: libcxgbi: fix NULL pointer dereference in cxgbi_device_destroy() | expand

Commit Message

Varun Prakash Dec. 18, 2019, 1:45 p.m. UTC
If cxgb4i_ddp_init() fails then cdev->cdev2ppm will be NULL,
so add a check for NULL pointer before dereferencing it.

Signed-off-by: Varun Prakash <varun@chelsio.com>
---
 drivers/scsi/cxgbi/libcxgbi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Martin K. Petersen Dec. 19, 2019, 11:48 p.m. UTC | #1
Varun,

> If cxgb4i_ddp_init() fails then cdev->cdev2ppm will be NULL,
> so add a check for NULL pointer before dereferencing it.

Applied to 5.5/scsi-fixes, thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index c4e4b01..4bc794d 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -121,7 +121,8 @@  static inline void cxgbi_device_destroy(struct cxgbi_device *cdev)
 		"cdev 0x%p, p# %u.\n", cdev, cdev->nports);
 	cxgbi_hbas_remove(cdev);
 	cxgbi_device_portmap_cleanup(cdev);
-	cxgbi_ppm_release(cdev->cdev2ppm(cdev));
+	if (cdev->cdev2ppm)
+		cxgbi_ppm_release(cdev->cdev2ppm(cdev));
 	if (cdev->pmap.max_connect)
 		cxgbi_free_big_mem(cdev->pmap.port_csk);
 	kfree(cdev);