Skip to content

Commit 41db6f9

Browse files
davidarinzonkuba-moo
authored andcommitted
net: ena: Destroy correct number of xdp queues upon failure
The ena_setup_and_create_all_xdp_queues() function freed all the resources upon failure, after creating only xdp_num_queues queues, instead of freeing just the created ones. In this patch, the only resources that are freed, are the ones allocated right before the failure occurs. Fixes: 548c494 ("net: ena: Implement XDP_TX action") Signed-off-by: Shahar Itzko <[email protected]> Signed-off-by: David Arinzon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f99cd56 commit 41db6f9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/net/ethernet/amazon/ena/ena_netdev.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ static void ena_unmap_tx_buff(struct ena_ring *tx_ring,
7474
struct ena_tx_buffer *tx_info);
7575
static int ena_create_io_tx_queues_in_range(struct ena_adapter *adapter,
7676
int first_index, int count);
77+
static void ena_free_all_io_tx_resources_in_range(struct ena_adapter *adapter,
78+
int first_index, int count);
7779

7880
/* Increase a stat by cnt while holding syncp seqlock on 32bit machines */
7981
static void ena_increase_stat(u64 *statp, u64 cnt,
@@ -457,23 +459,22 @@ static void ena_init_all_xdp_queues(struct ena_adapter *adapter)
457459

458460
static int ena_setup_and_create_all_xdp_queues(struct ena_adapter *adapter)
459461
{
462+
u32 xdp_first_ring = adapter->xdp_first_ring;
463+
u32 xdp_num_queues = adapter->xdp_num_queues;
460464
int rc = 0;
461465

462-
rc = ena_setup_tx_resources_in_range(adapter, adapter->xdp_first_ring,
463-
adapter->xdp_num_queues);
466+
rc = ena_setup_tx_resources_in_range(adapter, xdp_first_ring, xdp_num_queues);
464467
if (rc)
465468
goto setup_err;
466469

467-
rc = ena_create_io_tx_queues_in_range(adapter,
468-
adapter->xdp_first_ring,
469-
adapter->xdp_num_queues);
470+
rc = ena_create_io_tx_queues_in_range(adapter, xdp_first_ring, xdp_num_queues);
470471
if (rc)
471472
goto create_err;
472473

473474
return 0;
474475

475476
create_err:
476-
ena_free_all_io_tx_resources(adapter);
477+
ena_free_all_io_tx_resources_in_range(adapter, xdp_first_ring, xdp_num_queues);
477478
setup_err:
478479
return rc;
479480
}

0 commit comments

Comments
 (0)