From: Dan Carpenter <error27@gmail.com>
To: Ariana Lazar <ariana.lazar@microchip.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org
Subject: [bug report] iio: dac: mcp47feb02: Fix Vref validation [1-999] case
Date: Fri, 10 Apr 2026 08:50:22 +0300 [thread overview]
Message-ID: <adiPnla0M5EzvgD-@stanley.mountain> (raw)
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
reply other threads:[~2026-04-10 5:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=adiPnla0M5EzvgD-@stanley.mountain \
--to=error27@gmail.com \
--cc=andy@kernel.org \
--cc=ariana.lazar@microchip.com \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.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