Skip to contentSkip to conversation

megaraid: fix possible uninitialized-variable access in megadev_ioctl()

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 megaraid: fix possible uninitialized-variable access in megadev_ioctl()

The variable pthru_dma_hndl is not initialized at the beginning of the function megadev_ioctl(). It remains uninitialized if the variable uioc.xferlen is zero at line 3275. However, it is accessed at line 3311:
mc.xferaddr = (u32)data_dma_hndl;

To fix this possible bug, pthru_dma_hndl is initialized to zero at the beginning of the function megadev_ioctl().

---
 drivers/scsi/megaraid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/megaraid.c +1 -1
index 56910e94dbf2..8b0676b862fb 100644
@@ -2975,7 +2975,7 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
 	mega_passthru	*pthru;		/* copy user passthru here */
 	dma_addr_t	pthru_dma_hndl;
 	void		*data = NULL;	/* data to be transferred */
-	dma_addr_t	data_dma_hndl;	/* dma handle for data xfer area */
+	dma_addr_t	data_dma_hndl = 0;	/* dma handle for data xfer area */
 	megacmd_t	mc;
 #if MEGA_HAVE_STATS
 	megastat_t	__user *ustats = NULL;
Signature · 1 line
2.25.1