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: <20190318231554.8862-1-pakki001@umn.edu>
Date:   Mon, 18 Mar 2019 18:15:54 -0500
From:   Aditya Pakki <pakki001@....edu>
To:     pakki001@....edu
Cc:     kjlu@....edu, Lee Jones <lee.jones@...aro.org>,
        linux-kernel@...r.kernel.org
Subject: [PATCH] mfd: mc13xxx: i2c/spi Fix to avoid NULL pointer dereference

of_match_device can return NULL if no matching device is found. The patches
avoids a scenario causing null pointer dereference.

Signed-off-by: Aditya Pakki <pakki001@....edu>
---
 drivers/mfd/mc13xxx-i2c.c | 2 ++
 drivers/mfd/mc13xxx-spi.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c
index 67e4c9aa7d18..1fbc9713bb9a 100644
--- a/drivers/mfd/mc13xxx-i2c.c
+++ b/drivers/mfd/mc13xxx-i2c.c
@@ -80,6 +80,8 @@ static int mc13xxx_i2c_probe(struct i2c_client *client,
 	if (client->dev.of_node) {
 		const struct of_device_id *of_id =
 			of_match_device(mc13xxx_dt_ids, &client->dev);
+		if (!of_id)
+			return -ENODEV;
 		mc13xxx->variant = of_id->data;
 	} else {
 		mc13xxx->variant = (void *)id->driver_data;
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
index ee3411cc5ce4..c044a02bdb64 100644
--- a/drivers/mfd/mc13xxx-spi.c
+++ b/drivers/mfd/mc13xxx-spi.c
@@ -158,6 +158,8 @@ static int mc13xxx_spi_probe(struct spi_device *spi)
 	if (spi->dev.of_node) {
 		const struct of_device_id *of_id =
 			of_match_device(mc13xxx_dt_ids, &spi->dev);
+		if (!of_id)
+			return -ENODEV;
 
 		mc13xxx->variant = of_id->data;
 	} else {
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ