From: Camel Guo <camelg@axis.com>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>,
Camel Guo <Camel.Guo@axis.com>,
"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
"broonie@kernel.org" <broonie@kernel.org>,
"tiwai@suse.com" <tiwai@suse.com>,
"dmurphy@ti.com" <dmurphy@ti.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
kernel <kernel@axis.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] ASoC: tlv320adcx140: Avoid accessing invalid gpio_reset
Date: Wed, 9 Sep 2020 12:08:24 +0200 [thread overview]
Message-ID: <629c8afb-3feb-54c6-162e-4addb3c85908@axis.com> (raw)
In-Reply-To: <e791162b-1292-e1c4-3fca-b8936beeeb45@ti.com>
Hi Peter,
Thanks for your comment. I will make a new one like what you said.
On 9/8/20 2:03 PM, Peter Ujfalusi wrote:
> Hi,
>
> On 08/09/2020 14.59, Peter Ujfalusi wrote:
>>
>>
>> On 08/09/2020 11.35, Camel Guo wrote:
>>> 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;
>>
>> the correct fix is to:
>> dev_err(&i2c->dev, "Reset GPIO not defined\n");
>
> no need to print, I think gpio core will do that.
>
>> return PTR_ERR(adcx140->gpio_reset);
>>
>> If the reset GPIO is specified and you get error when requesting it as
>> optional, there is a reason for that.
>> For example deferred probing.
I agree! Please ignore this patch and I will make a new one like this.
>>
>>> + }
>>>
>>> adcx140->supply_areg = devm_regulator_get_optional(adcx140->dev,
>>> "areg");
>>>
>>
>> - Péter
>>
>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>>
>
> - Péter
>
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>
next prev parent reply other threads:[~2020-09-09 10:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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
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 [this message]
2020-09-08 17:20 ` Mark Brown
2020-09-09 10:06 ` Camel Guo
2020-09-09 11:22 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=629c8afb-3feb-54c6-162e-4addb3c85908@axis.com \
--to=camelg@axis.com \
--cc=Camel.Guo@axis.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=dmurphy@ti.com \
--cc=kernel@axis.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.ujfalusi@ti.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®