[krzk-github:n/qcom-ufs-opp-v2 14/16] drivers/opp/core.c:1215 dev_pm_opp_set_rate() error: uninitialized symbol 'ret'.

From: Dan Carpenter
Date: Fri Apr 15 2022 - 02:47:00 EST


tree: https://github.com/krzk/linux n/qcom-ufs-opp-v2
head: bf7d30c9329c87f06dff42b303a9bcfd2e1f54eb
commit: be46c855d54f763bfb95424e5204fe7496e2ee5f [14/16] PM: opp: allow control of multiple clocks
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220415/202204150900.qnJMf3Gu-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

New smatch warnings:
drivers/opp/core.c:1215 dev_pm_opp_set_rate() error: uninitialized symbol 'ret'.

Old smatch warnings:
drivers/opp/core.c:1197 dev_pm_opp_set_rate() warn: passing a valid pointer to 'PTR_ERR'
drivers/opp/core.c:2813 _opp_set_availability() warn: passing a valid pointer to 'PTR_ERR'
drivers/opp/core.c:2884 dev_pm_opp_adjust_voltage() warn: passing a valid pointer to 'PTR_ERR'

vim +/ret +1215 drivers/opp/core.c

386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1155 int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1156 {
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1157 struct opp_table *opp_table;
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1158 unsigned long freq = 0, temp_freq;
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1159 struct dev_pm_opp *opp = NULL;
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1160 int ret;
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1161
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1162 opp_table = _find_opp_table(dev);
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1163 if (IS_ERR(opp_table)) {
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1164 dev_err(dev, "%s: device's opp table doesn't exist\n", __func__);
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1165 return PTR_ERR(opp_table);
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1166 }
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1167
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1168 if (target_freq) {
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1169 /*
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1170 * For IO devices which require an OPP on some platforms/SoCs
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1171 * while just needing to scale the clock on some others
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1172 * we look for empty OPP tables with just a clock handle and
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1173 * scale only the clk. This makes dev_pm_opp_set_rate()
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1174 * equivalent to a clk_set_rate()
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1175 */
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1176 if (!_get_opp_count(opp_table)) {
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1177 if (opp_table->clks)
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1178 ret = _generic_set_opp_clk_only(dev,
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1179 opp_table->clks[0],
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1180 target_freq);

"ret" not initialized on else path.

386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1181 goto put_opp_table;
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1182 }
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1183
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1184 if (opp_table->clks)
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1185 freq = clk_round_rate(opp_table->clks[0], target_freq);
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1186 if ((long)freq <= 0)
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1187 freq = target_freq;
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1188
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1189 /*
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1190 * The clock driver may support finer resolution of the
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1191 * frequencies than the OPP table, don't update the frequency we
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1192 * pass to clk_set_rate() here.
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1193 */
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1194 temp_freq = freq;
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1195 opp = _find_freq_ceil(opp_table, &temp_freq);
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1196 if (IS_ERR(opp)) {
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1197 ret = PTR_ERR(opp);
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1198 dev_err(dev, "%s: failed to find OPP for freq %lu (%d)\n",
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1199 __func__, freq, ret);
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1200 goto put_opp_table;
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1201 }
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1202 /*
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1203 * opp->rates are used for scaling clocks, so be sure accurate
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1204 * 'freq' is used, instead what was defined via e.g. Devicetree.
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1205 */
be46c855d54f76 drivers/opp/core.c Krzysztof Kozlowski 2022-04-05 1206 opp->rates[0] = freq;
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1207 }
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1208
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1209 ret = _set_opp(dev, opp_table, opp, freq);
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1210
386ba854d9f316 drivers/opp/core.c Viresh Kumar 2021-01-21 1211 if (target_freq)
8a31d9d94297b1 drivers/base/power/opp/core.c Viresh Kumar 2017-01-23 1212 dev_pm_opp_put(opp);
052c6f19141dd1 drivers/base/power/opp/core.c Viresh Kumar 2017-01-23 1213 put_opp_table:
5b650b388844f2 drivers/base/power/opp/core.c Viresh Kumar 2017-01-23 1214 dev_pm_opp_put_opp_table(opp_table);
052c6f19141dd1 drivers/base/power/opp/core.c Viresh Kumar 2017-01-23 @1215 return ret;
6a0712f6f199e7 drivers/base/power/opp/core.c Viresh Kumar 2016-02-09 1216 }

--
0-DAY CI Kernel Test Service
https://01.org/lkp