Skip to content

Commit edb35b1

Browse files
Thomas-fouriermartinkpetersen
authored andcommitted
scsi: myrs: Fix dma_alloc_coherent() error check
Check for NULL return value with dma_alloc_coherent(), because DMA address is not always set by dma_alloc_coherent() on failure. Fixes: 7726618 ("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>
1 parent e79aa10 commit edb35b1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/scsi/myrs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,14 +498,14 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs,
498498
/* Temporary dma mapping, used only in the scope of this function */
499499
mbox = dma_alloc_coherent(&pdev->dev, sizeof(union myrs_cmd_mbox),
500500
&mbox_addr, GFP_KERNEL);
501-
if (dma_mapping_error(&pdev->dev, mbox_addr))
501+
if (!mbox)
502502
return false;
503503

504504
/* These are the base addresses for the command memory mailbox array */
505505
cs->cmd_mbox_size = MYRS_MAX_CMD_MBOX * sizeof(union myrs_cmd_mbox);
506506
cmd_mbox = dma_alloc_coherent(&pdev->dev, cs->cmd_mbox_size,
507507
&cs->cmd_mbox_addr, GFP_KERNEL);
508-
if (dma_mapping_error(&pdev->dev, cs->cmd_mbox_addr)) {
508+
if (!cmd_mbox) {
509509
dev_err(&pdev->dev, "Failed to map command mailbox\n");
510510
goto out_free;
511511
}
@@ -520,7 +520,7 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs,
520520
cs->stat_mbox_size = MYRS_MAX_STAT_MBOX * sizeof(struct myrs_stat_mbox);
521521
stat_mbox = dma_alloc_coherent(&pdev->dev, cs->stat_mbox_size,
522522
&cs->stat_mbox_addr, GFP_KERNEL);
523-
if (dma_mapping_error(&pdev->dev, cs->stat_mbox_addr)) {
523+
if (!stat_mbox) {
524524
dev_err(&pdev->dev, "Failed to map status mailbox\n");
525525
goto out_free;
526526
}
@@ -533,7 +533,7 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs,
533533
cs->fwstat_buf = dma_alloc_coherent(&pdev->dev,
534534
sizeof(struct myrs_fwstat),
535535
&cs->fwstat_addr, GFP_KERNEL);
536-
if (dma_mapping_error(&pdev->dev, cs->fwstat_addr)) {
536+
if (!cs->fwstat_buf) {
537537
dev_err(&pdev->dev, "Failed to map firmware health buffer\n");
538538
cs->fwstat_buf = NULL;
539539
goto out_free;

0 commit comments

Comments
 (0)