linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: tlv320adcx140: Avoid accessing invalid gpio_reset
@ 2020-09-08  8:35 Camel Guo
  2020-09-08  8:35 ` [PATCH 2/2] ASoC: tlv320adcx140: Wake up codec before accessing register Camel Guo
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Camel Guo @ 2020-09-08  8:35 UTC (permalink / raw)
  To: lgirdwood, broonie, tiwai, dmurphy
  Cc: alsa-devel, linux-kernel, kernel, Camel Guo

From: Camel Guo <camelg@axis.com>

When gpio_reset is not well defined in devicetree, the
adcx140->gpio_reset is an error code instead of NULL. In this case,
adcx140->gpio_reset should not be used by adcx140_reset. This commit
sets it NULL to avoid accessing an invalid variable.

Signed-off-by: Camel Guo <camelg@axis.com>
---
 sound/soc/codecs/tlv320adcx140.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 7ae6ec374be3..597dd1062943 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -984,8 +984,10 @@ static int adcx140_i2c_probe(struct i2c_client *i2c,
 
 	adcx140->gpio_reset = devm_gpiod_get_optional(adcx140->dev,
 						      "reset", GPIOD_OUT_LOW);
-	if (IS_ERR(adcx140->gpio_reset))
+	if (IS_ERR(adcx140->gpio_reset) || adcx140->gpio_reset == NULL) {
 		dev_info(&i2c->dev, "Reset GPIO not defined\n");
+		adcx140->gpio_reset = NULL;
+	}
 
 	adcx140->supply_areg = devm_regulator_get_optional(adcx140->dev,
 							   "areg");
-- 
2.20.1


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

end of thread, other threads:[~2020-09-09 15:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08  8:35 [PATCH 1/2] ASoC: tlv320adcx140: Avoid accessing invalid gpio_reset Camel Guo
2020-09-08  8:35 ` [PATCH 2/2] ASoC: tlv320adcx140: Wake up codec before accessing register Camel Guo
2020-09-08 11:49   ` Dan Murphy
2020-09-08 14:58     ` Dan Murphy
2020-09-08 11:55 ` [PATCH 1/2] ASoC: tlv320adcx140: Avoid accessing invalid gpio_reset Dan Murphy
2020-09-08 11:55   ` Dan Murphy
2020-09-08 11:59 ` Peter Ujfalusi
2020-09-08 12:03   ` Peter Ujfalusi
2020-09-08 12:03     ` Peter Ujfalusi
2020-09-09 10:08     ` Camel Guo
2020-09-08 17:20 ` Mark Brown
2020-09-09 10:06   ` Camel Guo
2020-09-09 11:22     ` 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).