Devicetree
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: Ryan Brue <ryanbrue.dev@gmail.com>,
	robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
	mfd@lists.linux.dev
Subject: Re: [PATCH 3/3] mfd: mt6397-core: Add mt6397 AUXADC support
Date: Wed, 16 Sep 2026 11:30:16 +0100	[thread overview]
Message-ID: <20260916103016.GK11487@google.com> (raw)
In-Reply-To: <20260916042448.A40941F000FF@smtp.kernel.org>

On Wed, 16 Sep 2026, sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] iio: mt6397-auxadc: hardware state leak on error paths

Please review, explain or fix the Sashiko review(s).

If this is a set, this request includes the other patches too.

> --
> 
> commit e17dd59587f106380c3ede8aa27c118b33350f88
> Author: Ryan Brue <ryanbrue.dev@gmail.com>
> 
> mfd: mt6397-core: Add mt6397 AUXADC support
> 
> The mt6397 PMIC includes an AUXADC. Register the AUXADC in the mt6397
> devices array to allow the corresponding driver to probe using compatible
> string.
> 
> > diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
> > index 9ec9519965887..5d5f816492aaa 100644
> > --- a/drivers/mfd/mt6397-core.c
> > +++ b/drivers/mfd/mt6397-core.c
> > @@ -261,6 +261,9 @@ static const struct mfd_cell mt6359_devs[] = {
> >  
> >  static const struct mfd_cell mt6397_devs[] = {
> >  	{
> > +		.name = "mt6397-auxadc",
> > +		.of_compatible = "mediatek,mt6397-auxadc",
> 
> [Severity: Medium]
> Enabling this device exposes a hardware state leak on error paths in the
> mt6397-auxadc driver.
> 
> In mt6397_auxadc_isense_enable(), if the second regmap write fails, does the
> function return without unwinding the first write, leaving
> MT6397_CHR_CON16_ADCIN_VSEN_EN incorrectly enabled?
> 
> drivers/iio/adc/mt6397-auxadc.c:mt6397_auxadc_isense_enable() {
>     ...
> 	ret = regmap_update_bits(map, MT6397_CHR_CON16,
> 				 MT6397_CHR_CON16_ADCIN_SEL,
> 				 MT6397_CHR_CON16_ADCIN_VSEN_EN);
> 	if (ret)
> 		return ret;
> 
> 	return regmap_set_bits(map, MT6397_AUXADC_CON14,
> 			       MT6397_AUXADC_CON14_CH0_NORM_SEL |
> 			       MT6397_AUXADC_CON14_CH0_LBAT_SEL);
> }
> 
> Similarly, during teardown in mt6397_auxadc_isense_disable(), the use of the
> ?: operator short-circuits the sequence.
> 
> If the first regmap_clear_bits() fails, will it abandon the cleanup and skip
> disabling MT6397_CHR_CON16_ADCIN_SEL?
> 
> drivers/iio/adc/mt6397-auxadc.c:mt6397_auxadc_isense_disable() {
>     ...
> 	ret = regmap_clear_bits(map, MT6397_AUXADC_CON14,
> 				MT6397_AUXADC_CON14_CH0_NORM_SEL |
> 				MT6397_AUXADC_CON14_CH0_LBAT_SEL);
> 
> 	return ret ?: regmap_clear_bits(map, MT6397_CHR_CON16,
> 					MT6397_CHR_CON16_ADCIN_SEL);
> }
> 
> A similar issue appears in mt6397_auxadc_battemp_bias().
> 
> Does this function lack a rollback path if the second or third regmap
> operation fails, permanently leaking previously modified register states?
> 
> drivers/iio/adc/mt6397-auxadc.c:mt6397_auxadc_battemp_bias() {
>     ...
> 	if (on) {
> 		ret = regmap_set_bits(map, MT6397_AUXADC_CON0,
> 				      MT6397_AUXADC_CON0_BUF_PWD_ON);
> 		if (ret)
> 			return ret;
> 		ret = regmap_set_bits(map, MT6397_AUXADC_CON0,
> 				      MT6397_AUXADC_CON0_BUF_PWD_B);
> 		if (ret)
> 			return ret;
> 		return regmap_set_bits(map, MT6397_CHR_CON7,
> 				       MT6397_CHR_CON7_BATON_TDET_EN);
> 	}
>     ...
> }
> 
> > +	}, {
> >  		.name = "mt6397-rtc",
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260915-rbrue-suez-upstreaming-mt6397-auxadc-v1-0-d35d2ac3d6f0@gmail.com?part=3

-- 
Lee Jones

  reply	other threads:[~2026-09-16 10:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16  4:15 [PATCH 0/3] iio: adc: add mt6397 PMIC AUXADC support Ryan Brue
2026-09-16  4:15 ` [PATCH 1/3] dt-bindings: iio: adc: mediatek,mt6359-auxadc: add mt6397 PMIC AUXADC Ryan Brue
2026-09-16  4:18   ` sashiko-bot
2026-09-16  4:15 ` [PATCH 2/3] iio: adc: mt6397-auxadc: add mt6397 PMIC AUXADC driver Ryan Brue
2026-09-16  4:24   ` sashiko-bot
2026-09-16  9:55   ` Andy Shevchenko
2026-09-17 21:01     ` Ryan Brue
2026-09-17 21:06       ` Ryan Brue
2026-09-17  3:48   ` Jonathan Cameron
2026-09-17 23:00     ` Ryan Brue
2026-09-16  4:15 ` [PATCH 3/3] mfd: mt6397-core: Add mt6397 AUXADC support Ryan Brue
2026-09-16  4:24   ` sashiko-bot
2026-09-16 10:30     ` Lee Jones [this message]
2026-09-17 20:56     ` Ryan Brue
2026-09-16  9:50 ` [PATCH 0/3] iio: adc: add mt6397 PMIC " Andy Shevchenko
2026-09-17 20:24   ` Ryan Brue
2026-09-18  6:42     ` Andy Shevchenko

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=20260916103016.GK11487@google.com \
    --to=lee@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=ryanbrue.dev@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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