[PATCH] bus: imx-weim: fix pdev is NULL but dereferenced

Haowen Bai posted 1 patch 4 years, 2 months ago
drivers/bus/imx-weim.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
[PATCH] bus: imx-weim: fix pdev is NULL but dereferenced
Posted by Haowen Bai 4 years, 2 months ago
pdev is NULL,so we can't dereference it dev_err(&pdev->dev

Fixes: e6cb540 ("bus: imx-weim: add DT overlay support for WEIM bus")

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
 drivers/bus/imx-weim.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
index 60fbd42..31a2213 100644
--- a/drivers/bus/imx-weim.c
+++ b/drivers/bus/imx-weim.c
@@ -352,9 +352,8 @@ static int of_weim_notify(struct notifier_block *nb, unsigned long action,
 
 		pdev = of_find_device_by_node(rd->dn);
 		if (!pdev) {
-			dev_err(&pdev->dev,
-				"Could not find platform device for '%pOF'\n",
-				rd->dn);
+			pr_err("%s: Could not find platform device for '%pOF'\n",
+				__func__, rd->dn);
 
 			ret = notifier_from_errno(-EINVAL);
 		} else {
-- 
2.7.4

Re: [PATCH] bus: imx-weim: fix pdev is NULL but dereferenced
Posted by Ivan Bornyakov 4 years, 2 months ago
Hi!

On Wed, Mar 30, 2022 at 06:18:20PM +0800, Haowen Bai wrote:
> pdev is NULL,so we can't dereference it dev_err(&pdev->dev
> 
> Fixes: e6cb540 ("bus: imx-weim: add DT overlay support for WEIM bus")
> 
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
>  drivers/bus/imx-weim.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
> index 60fbd42..31a2213 100644
> --- a/drivers/bus/imx-weim.c
> +++ b/drivers/bus/imx-weim.c
> @@ -352,9 +352,8 @@ static int of_weim_notify(struct notifier_block *nb, unsigned long action,
>  
>  		pdev = of_find_device_by_node(rd->dn);
>  		if (!pdev) {
> -			dev_err(&pdev->dev,
> -				"Could not find platform device for '%pOF'\n",
> -				rd->dn);
> +			pr_err("%s: Could not find platform device for '%pOF'\n",
> +				__func__, rd->dn);
>  
>  			ret = notifier_from_errno(-EINVAL);
>  		} else {
> -- 
> 2.7.4
> 

This is a solid bug, but there is a fix already.

  https://lore.kernel.org/all/20220223035146.412499-1-wanjiabing@vivo.com/

For some reason it was not applied yet.