linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i40iw: Fix error unwinding when i40iw_hmc_sd_one fails
@ 2021-04-16  0:21 Shiraz Saleem
  2021-04-20 19:10 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Shiraz Saleem @ 2021-04-16  0:21 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, Sindhu Devale, Dan Carpenter, Shiraz Saleem

From: Sindhu Devale <sindhu.devale@intel.com>

When i40iw_hmc_sd_one fails, chunk is freed without the
deletion of chunk entry in the PBLE info list.

Fix it by adding the chunk entry to the PBLE info list only
after successful addition of SD in i40iw_hmc_sd_one.

This fixes a static checker warning reported in [1]

[1] https://lore.kernel.org/linux-rdma/YHV4CFXzqTm23AOZ@mwanda/

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sindhu Devale <sindhu.devale@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
---
 drivers/infiniband/hw/i40iw/i40iw_pble.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/i40iw/i40iw_pble.c b/drivers/infiniband/hw/i40iw/i40iw_pble.c
index 53e5cd1..146a414 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_pble.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_pble.c
@@ -393,12 +393,9 @@ static enum i40iw_status_code add_pble_pool(struct i40iw_sc_dev *dev,
 	i40iw_debug(dev, I40IW_DEBUG_PBLE, "next_fpm_addr = %llx chunk_size[%u] = 0x%x\n",
 		    pble_rsrc->next_fpm_addr, chunk->size, chunk->size);
 	pble_rsrc->unallocated_pble -= (chunk->size >> 3);
-	list_add(&chunk->list, &pble_rsrc->pinfo.clist);
 	sd_reg_val = (sd_entry_type == I40IW_SD_TYPE_PAGED) ?
 			sd_entry->u.pd_table.pd_page_addr.pa : sd_entry->u.bp.addr.pa;
-	if (sd_entry->valid)
-		return 0;
-	if (dev->is_pf) {
+	if (dev->is_pf && !sd_entry->valid) {
 		ret_code = i40iw_hmc_sd_one(dev, hmc_info->hmc_fn_id,
 					    sd_reg_val, idx->sd_idx,
 					    sd_entry->entry_type, true);
@@ -409,6 +406,7 @@ static enum i40iw_status_code add_pble_pool(struct i40iw_sc_dev *dev,
 	}
 
 	sd_entry->valid = true;
+	list_add(&chunk->list, &pble_rsrc->pinfo.clist);
 	return 0;
  error:
 	kfree(chunk);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] i40iw: Fix error unwinding when i40iw_hmc_sd_one fails
  2021-04-16  0:21 [PATCH] i40iw: Fix error unwinding when i40iw_hmc_sd_one fails Shiraz Saleem
@ 2021-04-20 19:10 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2021-04-20 19:10 UTC (permalink / raw)
  To: Shiraz Saleem; +Cc: dledford, linux-rdma, Sindhu Devale, Dan Carpenter

On Thu, Apr 15, 2021 at 07:21:04PM -0500, Shiraz Saleem wrote:
> From: Sindhu Devale <sindhu.devale@intel.com>
> 
> When i40iw_hmc_sd_one fails, chunk is freed without the
> deletion of chunk entry in the PBLE info list.
> 
> Fix it by adding the chunk entry to the PBLE info list only
> after successful addition of SD in i40iw_hmc_sd_one.
> 
> This fixes a static checker warning reported in [1]
> 
> [1] https://lore.kernel.org/linux-rdma/YHV4CFXzqTm23AOZ@mwanda/
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Sindhu Devale <sindhu.devale@intel.com>
> Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
> ---
>  drivers/infiniband/hw/i40iw/i40iw_pble.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

I added a fixes line an applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-20 19:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16  0:21 [PATCH] i40iw: Fix error unwinding when i40iw_hmc_sd_one fails Shiraz Saleem
2021-04-20 19:10 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).