Skip to contentSkip to conversation

i40iw: add pble resource files

bug report Dan Carpenter 2 participants 2 messages Apr 13, 2021 – Apr 14, 2021 InfiniBand

lore
Share & tools
lore
#0 lore raw

Hello Faisal Latif,

The patch 9715830157be: "i40iw: add pble resource files" from Jan 20, 2016, leads to the following static checker warning:

	drivers/infiniband/hw/i40iw/i40iw_pble.c:414 add_pble_pool()
	warn: '&chunk->list' not removed from list

drivers/infiniband/hw/i40iw/i40iw_pble.c

   391          }
   392          pble_rsrc->next_fpm_addr += chunk->size;
   393          i40iw_debug(dev, I40IW_DEBUG_PBLE, "next_fpm_addr = %llx chunk_size[%u] = 0x%x\n",
   394                      pble_rsrc->next_fpm_addr, chunk->size, chunk->size);
   395          pble_rsrc->unallocated_pble -= (chunk->size >> 3);
   396          list_add(&chunk->list, &pble_rsrc->pinfo.clist);
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

"chunk" is added to the list.

397 sd_reg_val = (sd_entry_type == I40IW_SD_TYPE_PAGED) ?
398 sd_entry->u.pd_table.pd_page_addr.pa : sd_entry->u.bp.addr.pa;
399 if (sd_entry->valid)
400 return 0;
401 if (dev->is_pf) {
402 ret_code = i40iw_hmc_sd_one(dev, hmc_info->hmc_fn_id,
403 sd_reg_val, idx->sd_idx,
404 sd_entry->entry_type, true);
405 if (ret_code) {
406 i40iw_pr_err("cqp cmd failed for sd (pbles)\n");

   407                          goto error;
                                ^^^^^^^^^^

We hit an error

408 }
409 }
410
411 sd_entry->valid = true;
412 return 0;
413 error:

   414          kfree(chunk);
                ^^^^^^^^^^^^

"chunk" is freed but it's still on the list

415 return ret_code;
416 }

regards,
dan carpenter

#1 lore raw
Quoted 43 lines

Subject: [bug report] i40iw: add pble resource files

Hello Faisal Latif,

The patch 9715830157be: "i40iw: add pble resource files" from Jan 20, 2016, leads to the following static checker warning:

	drivers/infiniband/hw/i40iw/i40iw_pble.c:414 add_pble_pool()
	warn: '&chunk->list' not removed from list

drivers/infiniband/hw/i40iw/i40iw_pble.c

   391          }
   392          pble_rsrc->next_fpm_addr += chunk->size;
   393          i40iw_debug(dev, I40IW_DEBUG_PBLE, "next_fpm_addr = %llx
chunk_size[%u] = 0x%x\n",
   394                      pble_rsrc->next_fpm_addr, chunk->size, chunk->size);
   395          pble_rsrc->unallocated_pble -= (chunk->size >> 3);
   396          list_add(&chunk->list, &pble_rsrc->pinfo.clist);
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

"chunk" is added to the list.

   397          sd_reg_val = (sd_entry_type == I40IW_SD_TYPE_PAGED) ?
   398                          sd_entry->u.pd_table.pd_page_addr.pa : sd_entry-
Quoted 1 line

u.bp.addr.pa;

399 if (sd_entry->valid)

   400                  return 0;
   401          if (dev->is_pf) {
   402                  ret_code = i40iw_hmc_sd_one(dev, hmc_info->hmc_fn_id,
   403                                              sd_reg_val, idx->sd_idx,
   404                                              sd_entry->entry_type, true);
   405                  if (ret_code) {
   406                          i40iw_pr_err("cqp cmd failed for sd (pbles)\n");
   407                          goto error;
                                ^^^^^^^^^^ We hit an error

   408                  }
   409          }
   410
   411          sd_entry->valid = true;
   412          return 0;
   413   error:
   414          kfree(chunk);
                ^^^^^^^^^^^^
Quoted 2 lines

"chunk" is freed but it's still on the list

Hi Dan - Thanks for the report and it looks legit. We will send a fix for it.

Shiraz