summaryrefslogtreecommitdiff
path: root/asoc/codecs/wcd9xxx-core.c
diff options
context:
space:
mode:
authorAditya Bavanari <abavanar@codeaurora.org>2019-06-21 13:03:02 +0530
committerAditya Bavanari <abavanar@codeaurora.org>2019-06-21 13:06:19 +0530
commit9584db3c2d9b5244b5fdf42ec38f934fff96c1b9 (patch)
treee1886bbad4bbdee74461ef23f83acf38b8ec133e /asoc/codecs/wcd9xxx-core.c
parentac2cc5456ab3823dea5f7376e279053d6c4ae826 (diff)
downloadmsm-extra-9584db3c2d9b5244b5fdf42ec38f934fff96c1b9.tar.gz
asoc: codecs: Fix NULL pointer dereference in wcd9xxx slim probe
When slim device is NULL or pdata allocation fails in wcd9xxx slim probe, devm_kfree uses slim device leading to a NULL pointer dereference. Fix this by returning from probe in these scenarios. Change-Id: I232661d8ba0320469bc4486e7dd82713e9b53d73 Signed-off-by: Aditya Bavanari <abavanar@codeaurora.org>
Diffstat (limited to 'asoc/codecs/wcd9xxx-core.c')
-rw-r--r--asoc/codecs/wcd9xxx-core.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/asoc/codecs/wcd9xxx-core.c b/asoc/codecs/wcd9xxx-core.c
index fd2e9335..0665ba69 100644
--- a/asoc/codecs/wcd9xxx-core.c
+++ b/asoc/codecs/wcd9xxx-core.c
@@ -1284,19 +1284,15 @@ static int wcd9xxx_slim_probe(struct slim_device *slim)
int ret = 0;
int intf_type;
+ if (!slim)
+ return -EINVAL;
+
intf_type = wcd9xxx_get_intf_type();
wcd9xxx = devm_kzalloc(&slim->dev, sizeof(struct wcd9xxx),
GFP_KERNEL);
- if (!wcd9xxx) {
- ret = -ENOMEM;
- goto err;
- }
-
- if (!slim) {
- ret = -EINVAL;
- goto err;
- }
+ if (!wcd9xxx)
+ return -ENOMEM;
if (intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
dev_dbg(&slim->dev, "%s:Codec is detected in I2C mode\n",