[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20190325211930.18730-1-kjlu@umn.edu>
Date: Mon, 25 Mar 2019 16:19:30 -0500
From: Kangjie Lu <kjlu@....edu>
To: kjlu@....edu
Cc: pakki001@....edu, Bard Liao <bardliao@...ltek.com>,
Oder Chiou <oder_chiou@...ltek.com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, alsa-devel@...a-project.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2] sound: codecs: fix a potential NULL pointer dereference
In case devm_kzalloc fails, the patch returns -ENOMEM to avoid
potential NULL pointer dereference.
Also add a check for rt5663_parse_dp to pass the error code
upstream
Signed-off-by: Kangjie Lu <kjlu@....edu>
Reviewed-by: Mukesh Ojha <mojha@...eaurora.org>
---
v2: pass error code upstream in the caller as suggested by
Mukesh Ojha <mojha@...eaurora.org>
---
sound/soc/codecs/rt5663.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c
index da6647015708..ab03ba499ad2 100644
--- a/sound/soc/codecs/rt5663.c
+++ b/sound/soc/codecs/rt5663.c
@@ -3480,6 +3480,8 @@ static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev)
table_size = sizeof(struct impedance_mapping_table) *
rt5663->pdata.impedance_sensing_num;
rt5663->imp_table = devm_kzalloc(dev, table_size, GFP_KERNEL);
+ if (!rt5663->imp_table)
+ return -ENOMEM;
device_property_read_u32_array(dev,
"realtek,impedance_sensing_table",
(u32 *)rt5663->imp_table, table_size);
@@ -3507,8 +3509,11 @@ static int rt5663_i2c_probe(struct i2c_client *i2c,
if (pdata)
rt5663->pdata = *pdata;
- else
- rt5663_parse_dp(rt5663, &i2c->dev);
+ else {
+ ret = rt5663_parse_dp(rt5663, &i2c->dev);
+ if (ret)
+ return ret;
+ }
for (i = 0; i < ARRAY_SIZE(rt5663->supplies); i++)
rt5663->supplies[i].supply = rt5663_supply_names[i];
--
2.17.1
Powered by blists - more mailing lists