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-prev] [day] [month] [year] [list]
Date:   Tue, 2 Apr 2019 07:13:48 +0100
From:   Lee Jones <lee.jones@...aro.org>
To:     Aditya Pakki <pakki001@....edu>
Cc:     kjlu@....edu, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mfd: mc13xxx: i2c/spi Fix to avoid NULL pointer
 dereference

On Mon, 18 Mar 2019, Aditya Pakki wrote:

> 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;

Are you sure this can happen?

I don't think this is possible if client->dev.of_node is non-NULL.

The 'if (client->dev.of_node)' above should see to that.

>  		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 {

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ