2021-06-25 13:01:47

by Dan Carpenter

[permalink] [raw]
Subject: [bug report] iwlwifi: support loading the reduced power table from UEFI

Hello Luca Coelho,

The patch 9dad325f9d57: "iwlwifi: support loading the reduced power
table from UEFI" from Jun 21, 2021, leads to the following static
checker warning:

drivers/net/wireless/intel/iwlwifi/fw/pnvm.c:332 iwl_pnvm_load()
error: uninitialized symbol 'len'.

drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
256 int iwl_pnvm_load(struct iwl_trans *trans,
257 struct iwl_notif_wait_data *notif_wait)
258 {
259 u8 *data;
260 size_t len;
^^^^^^^^^^

261 struct pnvm_sku_package *package;
262 struct iwl_notification_wait pnvm_wait;
263 static const u16 ntf_cmds[] = { WIDE_ID(REGULATORY_AND_NVM_GROUP,
264 PNVM_INIT_COMPLETE_NTFY) };
265 int ret;
266
267 /* if the SKU_ID is empty, there's nothing to do */
268 if (!trans->sku_id[0] && !trans->sku_id[1] && !trans->sku_id[2])
269 return 0;
270
271 /*
272 * If we already loaded (or tried to load) it before, we just
273 * need to set it again.
274 */
275 if (trans->pnvm_loaded) {
276 ret = iwl_trans_set_pnvm(trans, NULL, 0);
277 if (ret)
278 return ret;
279 goto skip_parse;
^^^^^^^^^^^^^^^

280 }
281
282 /* First attempt to get the PNVM from BIOS */
283 package = iwl_uefi_get_pnvm(trans, &len);
284 if (!IS_ERR_OR_NULL(package)) {
285 data = kmemdup(package->data, len, GFP_KERNEL);
286
287 /* free package regardless of whether kmemdup succeeded */
288 kfree(package);
289
290 if (data) {
291 /* we need only the data size */
292 len -= sizeof(*package);
293 goto parse;
294 }
295 }
296
297 /* If it's not available, try from the filesystem */
298 ret = iwl_pnvm_get_from_fs(trans, &data, &len);
299 if (ret) {
300 /*
301 * Pretend we've loaded it - at least we've tried and
302 * couldn't load it at all, so there's no point in
303 * trying again over and over.
304 */
305 trans->pnvm_loaded = true;
306
307 goto skip_parse;
308 }
309
310 parse:
311 iwl_pnvm_parse(trans, data, len);
312
313 kfree(data);
314
315 skip_parse:
316 data = NULL;
317 /* now try to get the reduce power table, if not loaded yet */
318 if (!trans->reduce_power_loaded) {
319 data = iwl_uefi_get_reduced_power(trans, &len);
320 if (IS_ERR_OR_NULL(data)) {
321 /*
322 * Pretend we've loaded it - at least we've tried and
323 * couldn't load it at all, so there's no point in
324 * trying again over and over.
325 */
326 trans->reduce_power_loaded = true;
327
328 goto skip_reduce_power;
329 }
330 }
331
332 ret = iwl_trans_set_reduce_power(trans, data, len);
^^^
Uninitialized

333 if (ret)
334 IWL_DEBUG_FW(trans,
335 "Failed to set reduce power table %d\n",
336 ret);
337 kfree(data);
338
339 skip_reduce_power:
340 iwl_init_notification_wait(notif_wait, &pnvm_wait,
341 ntf_cmds, ARRAY_SIZE(ntf_cmds),
342 iwl_pnvm_complete_fn, trans);
343

regards,
dan carpenter