lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Wed, 29 Nov 2023 07:11:52 -0800
From:   Haoran Liu <liuhaoran14@....com>
To:     jejb@...ux.ibm.com
Cc:     martin.petersen@...cle.com, linux-scsi@...r.kernel.org,
        linux-kernel@...r.kernel.org, Haoran Liu <liuhaoran14@....com>
Subject: [PATCH] [scsi] sni_53c710: Add error handling in snirm710_probe

The patch adds checks for the return values of dma_set_mask and ioremap.
Previously, the function did not handle potential failures of these calls,
which could lead to improper device initialization and unpredictable
behavior.

Although the error addressed by this patch may not occur in the current
environment, I still suggest implementing these error handling routines
if the function is not highly time-sensitive. As the environment evolves
or the code gets reused in different contexts, there's a possibility that
these errors might occur. Addressing them now can prevent potential
debugging efforts in the future, which could be quite resource-intensive.

Signed-off-by: Haoran Liu <liuhaoran14@....com>
---
 drivers/scsi/sni_53c710.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c
index 678651b9b4dd..41414d0c64f8 100644
--- a/drivers/scsi/sni_53c710.c
+++ b/drivers/scsi/sni_53c710.c
@@ -69,8 +69,19 @@ static int snirm710_probe(struct platform_device *dev)
 		return -ENOMEM;
 
 	hostdata->dev = &dev->dev;
-	dma_set_mask(&dev->dev, DMA_BIT_MASK(32));
+	rc = dma_set_mask(&dev->dev, DMA_BIT_MASK(32));
+	if (rc) {
+		printk(KERN_ERR "snirm710: dma_set_mask failed!\n");
+		goto out_kfree;
+	}
+
 	hostdata->base = ioremap(base, 0x100);
+	if (!hostdata->base) {
+		printk(KERN_ERR "snirm710: ioremap failed!\n");
+		rc = -ENOMEM;
+		goto out_kfree;
+	}
+
 	hostdata->differential = 0;
 
 	hostdata->clock = SNIRM710_CLOCK;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ