public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi-3w-9xxx: NULL check in twa_scsiop_execute_scsi()
@ 2023-02-16 10:20 Alexander Sapozhnikov
  0 siblings, 0 replies; only message in thread
From: Alexander Sapozhnikov @ 2023-02-16 10:20 UTC (permalink / raw)
  To: Adam Radford
  Cc: Alexandr Sapozhnikov, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi, linux-kernel, lvc-project

From: Alexandr Sapozhnikov <alsp705@gmail.com>

After having been compared to NULL value at 3w-9xxx.c:1829,
pointer 'srb' is passed as 1st parameter in call to function 
'scsi_sg_count' at 3w-9xxx.c:1844, where it is dereferenced.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
---
 drivers/scsi/3w-9xxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 6cb9cca..5a99294 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1841,7 +1841,7 @@ static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
 	if (!sglistarg) {
 		/* Map sglist from scsi layer to cmd packet */
 
-		if (scsi_sg_count(srb)) {
+		if (srb && scsi_sg_count(srb)) {
 			if (!twa_command_mapped(srb)) {
 				if (srb->sc_data_direction == DMA_TO_DEVICE ||
 				    srb->sc_data_direction == DMA_BIDIRECTIONAL)
-- 
2.5.3


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

only message in thread, other threads:[~2023-02-16 10:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-16 10:20 [PATCH] scsi-3w-9xxx: NULL check in twa_scsiop_execute_scsi() Alexander Sapozhnikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox