linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: csiostor: fix possible null-pointer dereference in csio_eh_lun_reset_handler()
@ 2021-07-31  7:51 Tuo Li
  0 siblings, 0 replies; only message in thread
From: Tuo Li @ 2021-07-31  7:51 UTC (permalink / raw)
  To: jejb, martin.petersen, sumit.semwal, christian.koenig,
	colin.king, jiapeng.chong
  Cc: linux-scsi, linux-kernel, linux-media, dri-devel, linaro-mm-sig,
	baijiaju1990, Tuo Li, TOTE Robot

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.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Tuo Li <islituo@gmail.com>
---
 drivers/scsi/csiostor/csio_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c
index 56b9ad0a1ca0..df0bf8348860 100644
--- a/drivers/scsi/csiostor/csio_scsi.c
+++ b/drivers/scsi/csiostor/csio_scsi.c
@@ -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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-31  7:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-31  7:51 [PATCH] scsi: csiostor: fix possible null-pointer dereference in csio_eh_lun_reset_handler() Tuo Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).