diff mbox series

[v2] 53c700: add 'slot' check to NULL

Message ID 20230728123521.18293-1-adiupina@astralinux.ru (mailing list archive)
State Accepted
Headers show
Series [v2] 53c700: add 'slot' check to NULL | expand

Commit Message

Alexandra Diupina July 28, 2023, 12:35 p.m. UTC
Add a 'slot' check for a null value to avoid
dereferencing the null pointer

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

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Co-developed-by: Vladimir Telezhnikov <vtelezhnikov@astralinux.ru>
Signed-off-by: Vladimir Telezhnikov <vtelezhnikov@astralinux.ru>
Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
---
v2: Move the 'slot' variable check to an existing if-else expression
as James E.J. Bottomley <James.Bottomley@HansenPartnership.com> suggested
 drivers/scsi/53c700.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Martin K. Petersen July 31, 2023, 7:46 p.m. UTC | #1
On Fri, 28 Jul 2023 15:35:21 +0300, Alexandra Diupina wrote:

> Add a 'slot' check for a null value to avoid
> dereferencing the null pointer
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> 

Applied to 6.5/scsi-fixes, thanks!

[1/1] 53c700: add 'slot' check to NULL
      https://git.kernel.org/mkp/scsi/c/8366d1f1249a
diff mbox series

Patch

diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index e1e4f9d10887..857be0f3ae5b 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -1598,7 +1598,7 @@  NCR_700_intr(int irq, void *dev_id)
 				printk("scsi%d (%d:%d) PHASE MISMATCH IN SEND MESSAGE %d remain, return %p[%04x], phase %s\n", host->host_no, pun, lun, count, (void *)temp, temp - hostdata->pScript, sbcl_to_string(NCR_700_readb(host, SBCL_REG)));
 #endif
 				resume_offset = hostdata->pScript + Ent_SendMessagePhaseMismatch;
-			} else if(dsp >= to32bit(&slot->pSG[0].ins) &&
+			} else if (slot && dsp >= to32bit(&slot->pSG[0].ins) &&
 				  dsp <= to32bit(&slot->pSG[NCR_700_SG_SEGMENTS].ins)) {
 				int data_transfer = NCR_700_readl(host, DBC_REG) & 0xffffff;
 				int SGcount = (dsp - to32bit(&slot->pSG[0].ins))/sizeof(struct NCR_700_SG_List);