Re: [PATCH v2] soundwire: intel_init: test link->cdns

2021-04-05 Thread Vinod Koul
On 06-04-21, 09:01, Bard Liao wrote:
> intel_link_probe() could return error and dev_get_drvdata() will return
> null in such case. So we have to test link->cdns after
> link->cdns = dev_get_drvdata(>auxdev.dev);
> Otherwise, we will meet the "kernel NULL pointer dereference" error.

Applied, thanks

-- 
~Vinod


[PATCH v2] soundwire: intel_init: test link->cdns

2021-04-05 Thread Bard Liao
intel_link_probe() could return error and dev_get_drvdata() will return
null in such case. So we have to test link->cdns after
link->cdns = dev_get_drvdata(>auxdev.dev);
Otherwise, we will meet the "kernel NULL pointer dereference" error.

Signed-off-by: Bard Liao 
Reviewed-by: Ranjani Sridharan 
Reviewed-by: Rander Wang 
Reviewed-by: Pierre-Louis Bossart 
---
v2:
 - Rebase to latest code base.
---
 drivers/soundwire/intel_init.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c
index 05b726cdfebc..30ce95ec2d70 100644
--- a/drivers/soundwire/intel_init.c
+++ b/drivers/soundwire/intel_init.c
@@ -178,6 +178,15 @@ static struct sdw_intel_ctx
link->pdev = pdev;
link->cdns = platform_get_drvdata(pdev);
 
+   if (!link->cdns) {
+   dev_err(>dev, "failed to get link->cdns\n");
+   /*
+* 1 will be subtracted from i in the err label, but we 
need to call
+* intel_link_dev_unregister for this ldev, so plus 1 
now
+*/
+   i++;
+   goto err;
+   }
list_add_tail(>list, >link_list);
bus = >cdns->bus;
/* Calculate number of slaves */
-- 
2.17.1