diff mbox series

[3/7] ASoC: cs42l43: Check error from device_property_read_u32_array

Message ID 20240124165558.1876407-3-ckeepax@opensource.cirrus.com
State Accepted
Commit a2e7cf55db781654fdb2d3b2529e28c4d93e24fc
Headers show
Series [1/7] ASoC: cs42l43: Tidy up header includes | expand

Commit Message

Charles Keepax Jan. 24, 2024, 4:55 p.m. UTC
Whilst reading cirrus,buttons-ohms the error from
device_property_read_u32_array is not checked, whilst there is a
preceding device_property_count_u32 which is checked the property read
can still fail. Add the missing check.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l43-jack.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Andy Shevchenko Jan. 24, 2024, 10:26 p.m. UTC | #1
On Wed, Jan 24, 2024 at 6:56 PM Charles Keepax
<ckeepax@opensource.cirrus.com> wrote:
>
> Whilst reading cirrus,buttons-ohms the error from
> device_property_read_u32_array is not checked, whilst there is a

..._array()

> preceding device_property_count_u32 which is checked the property read

..._u32()

> can still fail. Add the missing check.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
diff mbox series

Patch

diff --git a/sound/soc/codecs/cs42l43-jack.c b/sound/soc/codecs/cs42l43-jack.c
index d0569577a8699..147c7017fd8b6 100644
--- a/sound/soc/codecs/cs42l43-jack.c
+++ b/sound/soc/codecs/cs42l43-jack.c
@@ -106,8 +106,13 @@  int cs42l43_set_jack(struct snd_soc_component *component,
 			goto error;
 		}
 
-		device_property_read_u32_array(cs42l43->dev, "cirrus,buttons-ohms",
-					       priv->buttons, ret);
+		ret = device_property_read_u32_array(cs42l43->dev, "cirrus,buttons-ohms",
+						     priv->buttons, ret);
+		if (ret < 0) {
+			dev_err(priv->dev, "Property cirrus,button-ohms malformed: %d\n",
+				ret);
+			goto error;
+		}
 	} else {
 		priv->buttons[0] = 70;
 		priv->buttons[1] = 185;