Re: [PATCH] iio: dac: Fix passing uninitialized vref1_uV for no Vref1 case
From: Jonathan Cameron
Date: Mon Apr 20 2026 - 08:11:48 EST
On Tue, 14 Apr 2026 15:33:38 +0300
Ariana Lazar <ariana.lazar@xxxxxxxxxxxxx> wrote:
> Initialize vref1_uV variable to 0 before calling
> mcp47feb02_init_ch_scales() in mcp47feb02_probe() to avoid passing an
> uninitialized value when have_ext_vref1 is false.
>
> Fixes: dd154646d292 ("iio: dac: mcp47feb02: Fix Vref validation [1-999] case")
> Reported-by: Dan Carpenter <error27@xxxxxxxxx>
> Closes: https://lore.kernel.org/all/adiPnla0M5EzvgD-@stanley.mountain/
> Signed-off-by: Ariana Lazar <ariana.lazar@xxxxxxxxxxxxx>
> ---
> drivers/iio/dac/mcp47feb02.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/dac/mcp47feb02.c b/drivers/iio/dac/mcp47feb02.c
> index faccb804a5ed548088aaf83266b16ed45a92916c..efd4847913e46a4fa1b671aa9c5bd3e1430406b7 100644
> --- a/drivers/iio/dac/mcp47feb02.c
> +++ b/drivers/iio/dac/mcp47feb02.c
> @@ -1095,9 +1095,10 @@ static int mcp47feb02_probe(struct i2c_client *client)
> {
> const struct mcp47feb02_features *chip_features;
> struct device *dev = &client->dev;
> + int vdd_uV, vref_uV, vref1_uV;
> struct mcp47feb02_data *data;
> struct iio_dev *indio_dev;
> - int vref1_uV, vref_uV, vdd_uV, ret;
I haven't caught up with the rest of the discussion yet, but this change
seems to be superficial style stuff. Doesn't belong in a fix patch.
Thanks,
Jonathan
> + int ret;
>
> indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
> if (!indio_dev)
> @@ -1146,13 +1147,13 @@ static int mcp47feb02_probe(struct i2c_client *client)
> dev_dbg(dev, "Vref is unavailable.\n");
> }
>
> + vref1_uV = 0;
> if (chip_features->have_ext_vref1) {
> ret = devm_regulator_get_enable_read_voltage(dev, "vref1");
> if (ret > 0) {
> vref1_uV = ret;
> data->use_vref1 = true;
> } else {
> - vref1_uV = 0;
> dev_dbg(dev, "using internal band gap as voltage reference 1.\n");
> dev_dbg(dev, "Vref1 is unavailable.\n");
> }
>
> ---
> base-commit: 51e7665ab81f02adc80a1219c260ee678e9c6eb8
> change-id: 20260414-mcp47feb02-fix4-614de9334f22
>
> Best regards,