Skip to content

Commit 2a7e8b1

Browse files
Thangaraj Samynathanjfvogel
authored andcommitted
net: lan743x: Fix memleak issue when GSO enabled
[ Upstream commit 2d52e2e38b85c8b7bc00dca55c2499f46f8c8198 ] Always map the `skb` to the LS descriptor. Previously skb was mapped to EXT descriptor when the number of fragments is zero with GSO enabled. Mapping the skb to EXT descriptor prevents it from being freed, leading to a memory leak Fixes: 23f0703 ("lan743x: Add main source files for new lan743x driver") Signed-off-by: Thangaraj Samynathan <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 189b05f189cac9fd233ef04d31cb5078c4d09c39) Signed-off-by: Jack Vogel <[email protected]>
1 parent 414e00f commit 2a7e8b1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

drivers/net/ethernet/microchip/lan743x_main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,6 +1815,7 @@ static void lan743x_tx_frame_add_lso(struct lan743x_tx *tx,
18151815
if (nr_frags <= 0) {
18161816
tx->frame_data0 |= TX_DESC_DATA0_LS_;
18171817
tx->frame_data0 |= TX_DESC_DATA0_IOC_;
1818+
tx->frame_last = tx->frame_first;
18181819
}
18191820
tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail];
18201821
tx_descriptor->data0 = cpu_to_le32(tx->frame_data0);
@@ -1884,6 +1885,7 @@ static int lan743x_tx_frame_add_fragment(struct lan743x_tx *tx,
18841885
tx->frame_first = 0;
18851886
tx->frame_data0 = 0;
18861887
tx->frame_tail = 0;
1888+
tx->frame_last = 0;
18871889
return -ENOMEM;
18881890
}
18891891

@@ -1924,16 +1926,18 @@ static void lan743x_tx_frame_end(struct lan743x_tx *tx,
19241926
TX_DESC_DATA0_DTYPE_DATA_) {
19251927
tx->frame_data0 |= TX_DESC_DATA0_LS_;
19261928
tx->frame_data0 |= TX_DESC_DATA0_IOC_;
1929+
tx->frame_last = tx->frame_tail;
19271930
}
19281931

1929-
tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail];
1930-
buffer_info = &tx->buffer_info[tx->frame_tail];
1932+
tx_descriptor = &tx->ring_cpu_ptr[tx->frame_last];
1933+
buffer_info = &tx->buffer_info[tx->frame_last];
19311934
buffer_info->skb = skb;
19321935
if (time_stamp)
19331936
buffer_info->flags |= TX_BUFFER_INFO_FLAG_TIMESTAMP_REQUESTED;
19341937
if (ignore_sync)
19351938
buffer_info->flags |= TX_BUFFER_INFO_FLAG_IGNORE_SYNC;
19361939

1940+
tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail];
19371941
tx_descriptor->data0 = cpu_to_le32(tx->frame_data0);
19381942
tx->frame_tail = lan743x_tx_next_index(tx, tx->frame_tail);
19391943
tx->last_tail = tx->frame_tail;

drivers/net/ethernet/microchip/lan743x_main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ struct lan743x_tx {
980980
u32 frame_first;
981981
u32 frame_data0;
982982
u32 frame_tail;
983+
u32 frame_last;
983984

984985
struct lan743x_tx_buffer_info *buffer_info;
985986

0 commit comments

Comments
 (0)