Skip to content

Commit b3bb862

Browse files
Gerhard Englederkuba-moo
authored andcommitted
tsnep: Fix tsnep_tx_unmap() error path usage
If tsnep_tx_map() fails, then tsnep_tx_unmap() shall start at the write index like tsnep_tx_map(). This is different to the normal operation. Thus, add an additional parameter to tsnep_tx_unmap() to enable start at different positions for successful TX and failed TX. Fixes: 403f69b ("tsnep: Add TSN endpoint Ethernet MAC driver") Signed-off-by: Gerhard Engleder <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 73afd78 commit b3bb862

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/ethernet/engleder/tsnep_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,14 @@ static int tsnep_tx_map(struct sk_buff *skb, struct tsnep_tx *tx, int count)
340340
return 0;
341341
}
342342

343-
static void tsnep_tx_unmap(struct tsnep_tx *tx, int count)
343+
static void tsnep_tx_unmap(struct tsnep_tx *tx, int index, int count)
344344
{
345345
struct device *dmadev = tx->adapter->dmadev;
346346
struct tsnep_tx_entry *entry;
347347
int i;
348348

349349
for (i = 0; i < count; i++) {
350-
entry = &tx->entry[(tx->read + i) % TSNEP_RING_SIZE];
350+
entry = &tx->entry[(index + i) % TSNEP_RING_SIZE];
351351

352352
if (entry->len) {
353353
if (i == 0)
@@ -395,7 +395,7 @@ static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff *skb,
395395

396396
retval = tsnep_tx_map(skb, tx, count);
397397
if (retval != 0) {
398-
tsnep_tx_unmap(tx, count);
398+
tsnep_tx_unmap(tx, tx->write, count);
399399
dev_kfree_skb_any(entry->skb);
400400
entry->skb = NULL;
401401

@@ -464,7 +464,7 @@ static bool tsnep_tx_poll(struct tsnep_tx *tx, int napi_budget)
464464
if (skb_shinfo(entry->skb)->nr_frags > 0)
465465
count += skb_shinfo(entry->skb)->nr_frags;
466466

467-
tsnep_tx_unmap(tx, count);
467+
tsnep_tx_unmap(tx, tx->read, count);
468468

469469
if ((skb_shinfo(entry->skb)->tx_flags & SKBTX_IN_PROGRESS) &&
470470
(__le32_to_cpu(entry->desc_wb->properties) &

0 commit comments

Comments
 (0)