Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: qedf: Fix potential dereference of NULL pointer

The return value of dma_alloc_coherent() needs to be checked to avoid use
of NULL pointer in case of an allocation failure.

Link: https://lore.kernel.org/r/20211216101449.375953-1-jiasheng@iscas.ac.cn
Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Jiasheng Jiang and committed by
Martin K. Petersen
aa7069d8 c77b1f8a

+2
+2
drivers/scsi/qedf/qedf_main.c
··· 1415 1415 */ 1416 1416 term_params = dma_alloc_coherent(&qedf->pdev->dev, QEDF_TERM_BUFF_SIZE, 1417 1417 &term_params_dma, GFP_KERNEL); 1418 + if (!term_params) 1419 + return; 1418 1420 1419 1421 QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_CONN, "Uploading connection " 1420 1422 "port_id=%06x.\n", fcport->rdata->ids.port_id);