]> www.infradead.org Git - users/hch/misc.git/commitdiff
scsi: myrs: Fix dma_alloc_coherent() error check
authorThomas Fourier <fourier.thomas@gmail.com>
Fri, 25 Jul 2025 08:31:06 +0000 (10:31 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 20 Aug 2025 02:30:57 +0000 (22:30 -0400)
Check for NULL return value with dma_alloc_coherent(), because DMA
address is not always set by dma_alloc_coherent() on failure.

Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Link: https://lore.kernel.org/r/20250725083112.43975-2-fourier.thomas@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/myrs.c

index 95af3bb03834c3200ae42c9bceb3762681eec621..a58abd796603b05a3896289dfcca2d04e974c672 100644 (file)
@@ -498,14 +498,14 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs,
        /* Temporary dma mapping, used only in the scope of this function */
        mbox = dma_alloc_coherent(&pdev->dev, sizeof(union myrs_cmd_mbox),
                                  &mbox_addr, GFP_KERNEL);
-       if (dma_mapping_error(&pdev->dev, mbox_addr))
+       if (!mbox)
                return false;
 
        /* These are the base addresses for the command memory mailbox array */
        cs->cmd_mbox_size = MYRS_MAX_CMD_MBOX * sizeof(union myrs_cmd_mbox);
        cmd_mbox = dma_alloc_coherent(&pdev->dev, cs->cmd_mbox_size,
                                      &cs->cmd_mbox_addr, GFP_KERNEL);
-       if (dma_mapping_error(&pdev->dev, cs->cmd_mbox_addr)) {
+       if (!cmd_mbox) {
                dev_err(&pdev->dev, "Failed to map command mailbox\n");
                goto out_free;
        }
@@ -520,7 +520,7 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs,
        cs->stat_mbox_size = MYRS_MAX_STAT_MBOX * sizeof(struct myrs_stat_mbox);
        stat_mbox = dma_alloc_coherent(&pdev->dev, cs->stat_mbox_size,
                                       &cs->stat_mbox_addr, GFP_KERNEL);
-       if (dma_mapping_error(&pdev->dev, cs->stat_mbox_addr)) {
+       if (!stat_mbox) {
                dev_err(&pdev->dev, "Failed to map status mailbox\n");
                goto out_free;
        }
@@ -533,7 +533,7 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs,
        cs->fwstat_buf = dma_alloc_coherent(&pdev->dev,
                                            sizeof(struct myrs_fwstat),
                                            &cs->fwstat_addr, GFP_KERNEL);
-       if (dma_mapping_error(&pdev->dev, cs->fwstat_addr)) {
+       if (!cs->fwstat_buf) {
                dev_err(&pdev->dev, "Failed to map firmware health buffer\n");
                cs->fwstat_buf = NULL;
                goto out_free;