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] [thread-next>] [day] [month] [year] [list]
Message-ID: <DBBPR04MB7930A304416458880D69E1C7873E9@DBBPR04MB7930.eurprd04.prod.outlook.com>
Date:   Tue, 1 Jun 2021 10:11:28 +0000
From:   Jacky Bai <ping.bai@....com>
To:     Tong Tiangen <tongtiangen@...wei.com>,
        Shawn Guo <shawnguo@...nel.org>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        Pengutronix Kernel Team <kernel@...gutronix.de>,
        Fabio Estevam <festevam@...il.com>,
        dl-linux-imx <linux-imx@....com>
CC:     "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH -next] soc: imx: gpc: add check for of_match_device in
 imx_gpc_old_dt_init

> Subject: [PATCH -next] soc: imx: gpc: add check for of_match_device in
> imx_gpc_old_dt_init
> 
> Add check for of_match_device in imx_gpc_old_dt_init to avoid potential
> NULL dereference of of_id.
> 
> Signed-off-by: Tong Tiangen <tongtiangen@...wei.com>
> ---
>  drivers/soc/imx/gpc.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/soc/imx/gpc.c b/drivers/soc/imx/gpc.c index
> 90a8b2c0676f..017a5e2bd4e6 100644
> --- a/drivers/soc/imx/gpc.c
> +++ b/drivers/soc/imx/gpc.c
> @@ -403,14 +403,25 @@ static int imx_gpc_old_dt_init(struct device *dev,
> struct regmap *regmap,
> 
>  static int imx_gpc_probe(struct platform_device *pdev)  {
> -	const struct of_device_id *of_id =
> -			of_match_device(imx_gpc_dt_ids, &pdev->dev);
> -	const struct imx_gpc_dt_data *of_id_data = of_id->data;
> +	const struct of_device_id *of_id;
> +	const struct imx_gpc_dt_data *of_id_data;
>  	struct device_node *pgc_node;
>  	struct regmap *regmap;
>  	void __iomem *base;
>  	int ret;
> 
> +	of_id = of_match_device(imx_gpc_dt_ids, &pdev->dev);
> +	if (!of_id) {
> +		dev_err(&pdev->dev, "OF id missing\n");
> +		return -EINVAL;
> +	}
> +
> +	of_id_data = of_id->data;
> +	if (!of_id_data) {
> +		dev_err(&pdev->dev, "OF id data missing\n");
> +		return -EINVAL;
> +	}
> +

I think there is no chance to pass 'invalid of_id' and 'of_id_data' to the probe function.
Such check seems not really necessary.

BR
Jacky Bai

>  	pgc_node = of_get_child_by_name(pdev->dev.of_node, "pgc");
> 
>  	/* bail out if DT too old and doesn't provide the necessary info */
> --
> 2.18.0.huawei.25

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ