Skip to contentSkip to conversation

scsi: initio: Fix missing memory allocation modifier

PATCH New Yang Li 1 participant 1 message Dec 2, 2021 SCSI

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 scsi: initio: Fix missing memory allocation modifier

The function initio_probe_one() allocates a DMA buffer without the GFP_KERNEL modifier, fix this by using (GFP_KERNEL | GFP_DMA) instead of only GFP_DMA as the probe happens in non-interrupt context.

At the same time, change the if statement to the more typical kernel style.

Eliminate the follow smatch warning:
drivers/scsi/initio.c:2850 initio_probe_one() error: no modifiers for allocation.

---
 drivers/scsi/initio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/initio.c +2 -1
index 9cdee38..5982274 100644
@@ -2847,7 +2847,8 @@ static int initio_probe_one(struct pci_dev *pdev,
 
 	for (; num_scb >= MAX_TARGETS + 3; num_scb--) {
 		i = num_scb * sizeof(struct scsi_ctrl_blk);
-		if ((scb = kzalloc(i, GFP_DMA)) != NULL)
+		scb = kzalloc(i, (GFP_KERNEL | GFP_DMA));
+		if (scb)
 			break;
 	}
 
Signature · 1 line
1.8.3.1