Skip to contentSkip to conversation

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

PATCH Applied Varun Prakash 2 participants 2 messages Dec 18, 2019 – Dec 19, 2019 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: libcxgbi: fix NULL pointer dereference in cxgbi_device_destroy()

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

---
 drivers/scsi/cxgbi/libcxgbi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/cxgbi/libcxgbi.c +2 -1
index c4e4b01..4bc794d 100644
@@ -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);
Signature · 1 line
2.0.2
#1 lore raw

Varun,

Quoted 2 lines

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!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering