OSDN Git Service

scsi: qedf: Fix potential dereference of NULL pointer
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 16 Dec 2021 10:14:49 +0000 (18:14 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 5 Jan 2022 05:19:28 +0000 (00:19 -0500)
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>
drivers/scsi/qedf/qedf_main.c

index 1bf7a22..cdc66e2 100644 (file)
@@ -1415,6 +1415,8 @@ static void qedf_upload_connection(struct qedf_ctx *qedf,
         */
        term_params = dma_alloc_coherent(&qedf->pdev->dev, QEDF_TERM_BUFF_SIZE,
                &term_params_dma, GFP_KERNEL);
+       if (!term_params)
+               return;
 
        QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_CONN, "Uploading connection "
                   "port_id=%06x.\n", fcport->rdata->ids.port_id);