public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] iio: dac: mcp47feb02: Fix Vref validation [1-999] case
@ 2026-04-10  5:50 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2026-04-10  5:50 UTC (permalink / raw)
  To: Ariana Lazar; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, linux-iio

Hello Ariana Lazar,

Commit dd154646d292 ("iio: dac: mcp47feb02: Fix Vref validation
[1-999] case") from Mar 10, 2026 (linux-next), leads to the following
Smatch static checker warning:

	drivers/iio/dac/mcp47feb02.c:1165 mcp47feb02_probe()
	error: uninitialized symbol 'vref1_uV'.

drivers/iio/dac/mcp47feb02.c
    1094 static int mcp47feb02_probe(struct i2c_client *client)
    1095 {
    1096         const struct mcp47feb02_features *chip_features;
    1097         struct device *dev = &client->dev;
    1098         struct mcp47feb02_data *data;
    1099         struct iio_dev *indio_dev;
    1100         int vref1_uV, vref_uV, vdd_uV, ret;
    1101 
    1102         indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
    1103         if (!indio_dev)
    1104                 return -ENOMEM;
    1105 
    1106         data = iio_priv(indio_dev);
    1107         chip_features = i2c_get_match_data(client);
    1108         if (!chip_features)
    1109                 return -EINVAL;
    1110 
    1111         data->chip_features = chip_features;
    1112 
    1113         if (chip_features->have_eeprom) {
    1114                 data->regmap = devm_regmap_init_i2c(client, &mcp47feb02_regmap_config);
    1115                 indio_dev->info = &mcp47feb02_info;
    1116         } else {
    1117                 data->regmap = devm_regmap_init_i2c(client, &mcp47fvb02_regmap_config);
    1118                 indio_dev->info = &mcp47fvb02_info;
    1119         }
    1120         if (IS_ERR(data->regmap))
    1121                 return dev_err_probe(dev, PTR_ERR(data->regmap), "Error initializing i2c regmap\n");
    1122 
    1123         indio_dev->name = chip_features->name;
    1124 
    1125         ret = mcp47feb02_parse_fw(indio_dev, chip_features);
    1126         if (ret)
    1127                 return dev_err_probe(dev, ret, "Error parsing firmware data\n");
    1128 
    1129         ret = devm_mutex_init(dev, &data->lock);
    1130         if (ret)
    1131                 return ret;
    1132 
    1133         ret = devm_regulator_get_enable_read_voltage(dev, "vdd");
    1134         if (ret < 0)
    1135                 return ret;
    1136 
    1137         vdd_uV = ret;
    1138 
    1139         ret = devm_regulator_get_enable_read_voltage(dev, "vref");
    1140         if (ret > 0) {
    1141                 vref_uV = ret;
    1142                 data->use_vref = true;
    1143         } else {
    1144                 vref_uV = 0;
    1145                 dev_dbg(dev, "using internal band gap as voltage reference.\n");
    1146                 dev_dbg(dev, "Vref is unavailable.\n");
    1147         }
    1148 
    1149         if (chip_features->have_ext_vref1) {
    1150                 ret = devm_regulator_get_enable_read_voltage(dev, "vref1");
    1151                 if (ret > 0) {
    1152                         vref1_uV = ret;
    1153                         data->use_vref1 = true;
    1154                 } else {
    1155                         vref1_uV = 0;
    1156                         dev_dbg(dev, "using internal band gap as voltage reference 1.\n");
    1157                         dev_dbg(dev, "Vref1 is unavailable.\n");
    1158                 }
    1159         }

vref1_uV is uninitialized if ->have_ext_vref1 is false.

    1160 
    1161         ret = mcp47feb02_init_ctrl_regs(data);
    1162         if (ret)
    1163                 return dev_err_probe(dev, ret, "Error initialising vref register\n");
    1164 
--> 1165         ret = mcp47feb02_init_ch_scales(data, vdd_uV, vref_uV, vref1_uV);

Passing uninitialized variables is not allowed even if the variable
is not used.  (Unless the function is inlined and then it's not really
"passing" anything is it?)

    1166         if (ret)
    1167                 return ret;
    1168 
    1169         return devm_iio_device_register(dev, indio_dev);
    1170 }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-10  5:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10  5:50 [bug report] iio: dac: mcp47feb02: Fix Vref validation [1-999] case Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox