Message ID | 20221214032154.41665-1-jiasheng@iscas.ac.cn (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | scsi: ips: Add missing check for dma_alloc_coherent | expand |
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 16419aeec02d..26101f5b0434 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -6932,6 +6932,11 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr) if(ips_cd_boot && !ips_FlashData){ ips_FlashData = dma_alloc_coherent(&pci_dev->dev, PAGE_SIZE << 7, &ips_flashbusaddr, GFP_KERNEL); + if (!ips_FlashData) { + IPS_PRINTK(KERN_WARNING, pci_dev, + "Unable to allocate ips FlashData structure\n"); + return ips_abort_init(ha, index); + } } ha->enq = dma_alloc_coherent(&pci_dev->dev, sizeof (IPS_ENQ),
Add check for the return value of the dma_alloc_coherent in order to avoid NULL pointer dereference. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> --- drivers/scsi/ips.c | 5 +++++ 1 file changed, 5 insertions(+)