[PATCH v3] iio: adc: mt6359: fix unchecked return value in mt6358_read_imp
Andy Shevchenko
andriy.shevchenko at intel.com
Mon Apr 27 12:57:24 PDT 2026
On Mon, Apr 27, 2026 at 08:08:49PM +0100, Salah Triki wrote:
> In mt6358_read_imp(), the variable val_v is passed to regmap_read()
> but the return value is not checked. If the read fails, val_v remains
> uninitialized and its random stack content is subsequently reported
> as a measurement result.
>
> Initialize val_v to zero to ensure a predictable value is reported
> in case of bus failure and to prevent potential stack data leakage.
> This also satisfies static analyzers that might otherwise flag the
> variable as used uninitialized.
...
> const struct mtk_pmic_auxadc_info *cinfo = adc_dev->chip_info;
> struct regmap *regmap = adc_dev->regmap;
> u16 reg_adc0 = cinfo->regs[PMIC_AUXADC_ADC0];
> - u32 val_v;
> + u32 val_v = 0;
This is hard to maintain. Better to assign it just immediately before the first use.
> int ret;
Otherwise, LGTM.
--
With Best Regards,
Andy Shevchenko
More information about the Linux-mediatek
mailing list