linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: rt5663: Fix error handling of device_property_read_u32_array
@ 2019-01-05 13:44 Aditya Pakki
  2019-01-07 16:04 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Aditya Pakki @ 2019-01-05 13:44 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, Bard Liao, Oder Chiou, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel

In rt5663_parse_dp, the function device_property_read_u32_array() can
return an error. This fix adds a check to the latter as well as to the
callsite of rt5663_parse_dp in rt5663_i2c_probe.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 sound/soc/codecs/rt5663.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c
index da6647015708..2678842d8cd4 100644
--- a/sound/soc/codecs/rt5663.c
+++ b/sound/soc/codecs/rt5663.c
@@ -3480,7 +3480,7 @@ 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);
-		device_property_read_u32_array(dev,
+		return device_property_read_u32_array(dev,
 			"realtek,impedance_sensing_table",
 			(u32 *)rt5663->imp_table, table_size);
 	}
@@ -3507,8 +3507,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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: rt5663: Fix error handling of device_property_read_u32_array
  2019-01-05 13:44 [PATCH] ASoC: rt5663: Fix error handling of device_property_read_u32_array Aditya Pakki
@ 2019-01-07 16:04 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2019-01-07 16:04 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu, Bard Liao, Oder Chiou, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 619 bytes --]

On Sat, Jan 05, 2019 at 07:44:27AM -0600, Aditya Pakki wrote:

>  		rt5663->imp_table = devm_kzalloc(dev, table_size, GFP_KERNEL);
> -		device_property_read_u32_array(dev,
> +		return device_property_read_u32_array(dev,
>  			"realtek,impedance_sensing_table",
>  			(u32 *)rt5663->imp_table, table_size);

This is going to silently fail without giving any indication of what's
wrong which isn't great - it's not clear that completely failing to load
the driver is the best option here, and even if it is we should probably
tell the user what went wrong.

We're also not checking the result of the memory allocation...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-07 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-05 13:44 [PATCH] ASoC: rt5663: Fix error handling of device_property_read_u32_array Aditya Pakki
2019-01-07 16:04 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).