Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 403f69bbdbad ("tsnep: Add TSN endpoint Ethernet MAC driver")
Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Gerhard Engleder and committed by
Jakub Kicinski
b3bb8628 73afd781

+4 -4
+4 -4
drivers/net/ethernet/engleder/tsnep_main.c
··· 340 340 return 0; 341 341 } 342 342 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) 344 344 { 345 345 struct device *dmadev = tx->adapter->dmadev; 346 346 struct tsnep_tx_entry *entry; 347 347 int i; 348 348 349 349 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]; 351 351 352 352 if (entry->len) { 353 353 if (i == 0) ··· 395 395 396 396 retval = tsnep_tx_map(skb, tx, count); 397 397 if (retval != 0) { 398 - tsnep_tx_unmap(tx, count); 398 + tsnep_tx_unmap(tx, tx->write, count); 399 399 dev_kfree_skb_any(entry->skb); 400 400 entry->skb = NULL; 401 401 ··· 464 464 if (skb_shinfo(entry->skb)->nr_frags > 0) 465 465 count += skb_shinfo(entry->skb)->nr_frags; 466 466 467 - tsnep_tx_unmap(tx, count); 467 + tsnep_tx_unmap(tx, tx->read, count); 468 468 469 469 if ((skb_shinfo(entry->skb)->tx_flags & SKBTX_IN_PROGRESS) && 470 470 (__le32_to_cpu(entry->desc_wb->properties) &