diff options
author | Bard Liao <yung-chuan.liao@linux.intel.com> | 2021-04-06 03:01:01 +0200 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2021-04-06 06:56:44 +0200 |
commit | 14968dd36a507866be0edfc2a05d48c997da5d99 (patch) | |
tree | 25f529b4d55e29e032b9f555d12a721845b01614 /drivers/soundwire | |
parent | soundwire: qcom: handle return correctly in qcom_swrm_transport_params (diff) | |
download | linux-14968dd36a507866be0edfc2a05d48c997da5d99.tar.xz linux-14968dd36a507866be0edfc2a05d48c997da5d99.zip |
soundwire: intel_init: test link->cdns
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>
Link: https://lore.kernel.org/r/20210406010101.11442-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/soundwire')
-rw-r--r-- | drivers/soundwire/intel_init.c | 9 |
1 files changed, 9 insertions, 0 deletions
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(&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 */ |