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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220106092257.2738018-1-jiasheng@iscas.ac.cn>
Date:   Thu,  6 Jan 2022 17:22:57 +0800
From:   Jiasheng Jiang <jiasheng@...as.ac.cn>
To:     gregkh@...uxfoundation.org, knv418@...il.com
Cc:     linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] staging: kpc2000: kpc2000_spi: Check for null pointer after calling devm_ioremap

As the possible failure of the allocation, the devm_ioremap() may return
NULL pointer.
Then the kpspi->base is assigned to cs->base in kp_spi_setup() and used
in kp_spi_read_reg() and kp_spi_write_reg().
Therefore, it should be better to add the sanity check and return error
in order to avoid the dereference of the NULL pointer.

Fixes: 677b993a5749 ("staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
 drivers/staging/kpc2000/kpc2000_spi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 16ca18b8aa15..ead4aa0c988c 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -466,6 +466,10 @@ kp_spi_probe(struct platform_device *pldev)
 
 	kpspi->base = devm_ioremap(&pldev->dev, r->start,
 				   resource_size(r));
+	if (!kpspi->base) {
+		status = -ENOMEM;
+		goto free_master;
+	}
 
 	status = spi_register_master(master);
 	if (status < 0) {
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ