Skip to contentSkip to conversation

NULL check in twl_scsiop_execute_scsi()

PATCH New Alexander Sapozhnikov 1 participant 1 message Feb 16, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NULL check in twl_scsiop_execute_scsi()

From: Alexandr Sapozhnikov <[email protected]>

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

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

---
 drivers/scsi/3w-sas.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/3w-sas.c +1 -1
index 3ebe661..674c130 100644
@@ -333,7 +333,7 @@ static int twl_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)) {
 			sg_count = scsi_dma_map(srb);
 			if (sg_count <= 0)
 				goto out;
Signature · 1 line
2.5.3