Skip to contentSkip to conversation

scsi: csiostor: fix possible null-pointer dereference in csio_eh_lun_reset_handler()

PATCH New Tuo Li 1 participant 1 message Jul 31, 2021

Subsystems (2)
lore
Share & tools
lore

Tuo Li

author
#0 lore raw

PATCH 1/1 scsi: csiostor: fix possible null-pointer dereference in csio_eh_lun_reset_handler()

The variable rn is checked in:
if (!rn)

If rn is NULL, the program goes to the label fail:
fail:

    CSIO_INC_STATS(rn, n_lun_rst_fail);

However, rn is dereferenced in this macro:
#define CSIO_INC_STATS(elem, val) ((elem)->stats.val++)

To fix this possible null-pointer dereference, the function returns FAILED directly if rn is NULL.

---
 drivers/scsi/csiostor/csio_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/csiostor/csio_scsi.c +1 -1
index 56b9ad0a1ca0..df0bf8348860 100644
@@ -2070,7 +2070,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
 	struct csio_scsi_level_data sld;
 
 	if (!rn)
-		goto fail;
+		return FAILED;
 
 	csio_dbg(hw, "Request to reset LUN:%llu (ssni:0x%x tgtid:%d)\n",
 		      cmnd->device->lun, rn->flowid, rn->scsi_id);
Signature · 1 line
2.25.1