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  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:   Fri, 22 Mar 2019 16:44:49 +0000
From:   Steven Price <steven.price@....com>
To:     Aditya Pakki <pakki001@....edu>
Cc:     kjlu@....edu, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        Sudeep Holla <sudeep.holla@....com>
Subject: Re: [PATCH] firmware: arm_scmi: Fix to check return value of
 of_match_device

On 18/03/2019 23:04, Aditya Pakki wrote:
> of_match_device can return NULL if no matching device is found. This patch
> checks and returns -ENODEV in such a scenario.
> 
> Signed-off-by: Aditya Pakki <pakki001@....edu>
> ---
>  drivers/firmware/arm_scmi/driver.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 8f952f2f1a29..0e0330b44b7b 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -799,6 +799,8 @@ static int scmi_probe(struct platform_device *pdev)
>  	}
>  
>  	desc = of_match_device(scmi_of_match, dev)->data;
> +	if (!desc)
> +		return -ENODEV;

If of_match_device() returns NULL, we've already dereferenced it due to
the "->data" access.

This would be better changed to be a call to of_device_get_match_data()
which handles the NULL return gracefully.

Steve

Powered by blists - more mailing lists