* [PATCH] soundwire: intel_init: test link->cdns
@ 2021-03-31 1:02 Bard Liao
2021-04-01 7:21 ` Vinod Koul
0 siblings, 1 reply; 3+ messages in thread
From: Bard Liao @ 2021-03-31 1:02 UTC (permalink / raw)
To: alsa-devel, vkoul
Cc: vinod.koul, linux-kernel, gregkh, srinivas.kandagatla,
rander.wang, hui.wang, pierre-louis.bossart, sanyog.r.kale,
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(&ldev->auxdev.dev);
Otherwise, we will meet the "kernel NULL pointer dereference" error.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
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 5b32a2ffd376..5ef5bd0defab 100644
--- a/drivers/soundwire/intel_init.c
+++ b/drivers/soundwire/intel_init.c
@@ -250,6 +250,15 @@ static struct sdw_intel_ctx
link = &ldev->link_res;
link->cdns = dev_get_drvdata(&ldev->auxdev.dev);
+ if (!link->cdns) {
+ dev_err(&adev->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(&link->list, &ctx->link_list);
bus = &link->cdns->bus;
/* Calculate number of slaves */
--
2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] soundwire: intel_init: test link->cdns
2021-03-31 1:02 [PATCH] soundwire: intel_init: test link->cdns Bard Liao
@ 2021-04-01 7:21 ` Vinod Koul
2021-04-01 14:31 ` Pierre-Louis Bossart
0 siblings, 1 reply; 3+ messages in thread
From: Vinod Koul @ 2021-04-01 7:21 UTC (permalink / raw)
To: Bard Liao
Cc: alsa-devel, linux-kernel, gregkh, srinivas.kandagatla,
rander.wang, hui.wang, pierre-louis.bossart, sanyog.r.kale,
bard.liao
On 31-03-21, 09:02, 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(&ldev->auxdev.dev);
> Otherwise, we will meet the "kernel NULL pointer dereference" error.
This fails to apply for me
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] soundwire: intel_init: test link->cdns
2021-04-01 7:21 ` Vinod Koul
@ 2021-04-01 14:31 ` Pierre-Louis Bossart
0 siblings, 0 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2021-04-01 14:31 UTC (permalink / raw)
To: Vinod Koul, Bard Liao
Cc: alsa-devel, gregkh, linux-kernel, hui.wang, sanyog.r.kale,
rander.wang, bard.liao
On 4/1/21 2:21 AM, Vinod Koul wrote:
> On 31-03-21, 09:02, 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(&ldev->auxdev.dev);
>> Otherwise, we will meet the "kernel NULL pointer dereference" error.
>
> This fails to apply for me
probably a dependency on the auxiliary bus transition?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-01 18:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 1:02 [PATCH] soundwire: intel_init: test link->cdns Bard Liao
2021-04-01 7:21 ` Vinod Koul
2021-04-01 14:31 ` Pierre-Louis Bossart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®