Skip to content

Commit 9acfc57

Browse files
JoseExpositokuba-moo
authored andcommitted
net: mana: Fix memory leak in mana_hwc_create_wq
If allocating the DMA buffer fails, mana_hwc_destroy_wq was called without previously storing the pointer to the queue. In order to avoid leaking the pointer to the queue, store it as soon as it is allocated. Addresses-Coverity-ID: 1484720 ("Resource leak") Signed-off-by: José Expósito <[email protected]> Reviewed-by: Dexuan Cui <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ae68d93 commit 9acfc57

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/net/ethernet/microsoft/mana/hw_channel.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,16 @@ static int mana_hwc_create_wq(struct hw_channel_context *hwc,
480480
if (err)
481481
goto out;
482482

483-
err = mana_hwc_alloc_dma_buf(hwc, q_depth, max_msg_size,
484-
&hwc_wq->msg_buf);
485-
if (err)
486-
goto out;
487-
488483
hwc_wq->hwc = hwc;
489484
hwc_wq->gdma_wq = queue;
490485
hwc_wq->queue_depth = q_depth;
491486
hwc_wq->hwc_cq = hwc_cq;
492487

488+
err = mana_hwc_alloc_dma_buf(hwc, q_depth, max_msg_size,
489+
&hwc_wq->msg_buf);
490+
if (err)
491+
goto out;
492+
493493
*hwc_wq_ptr = hwc_wq;
494494
return 0;
495495
out:

0 commit comments

Comments
 (0)