Skip to content

Commit bbb18f7

Browse files
ilanpeer2jmberg-intel
authored andcommitted
wifi: iwlwifi: pcie: Fix TSO preparation
The allocation of the scatter gather data structure should be done based on the number of memory chunks that need to be mapped, and it is not dependent on the overall payload length. Fix it. In addition, as the skb_to_sgvec() function returns an 'int' do not assign it to an 'unsigned int' as otherwise the error check would be useless. Fixes: 7f5e303 ("wifi: iwlwifi: map entire SKB when sending AMSDUs") Signed-off-by: Ilan Peer <[email protected]> Signed-off-by: Miri Korenblit <[email protected]> Link: https://patch.msgid.link/20250306122425.8c0e23a3d583.I3cb4d6768c9d28ce3da6cd0a6c65466176cfc1ee@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent d048c84 commit bbb18f7

File tree

1 file changed

+6
-5
lines changed
  • drivers/net/wireless/intel/iwlwifi/pcie

1 file changed

+6
-5
lines changed

drivers/net/wireless/intel/iwlwifi/pcie/tx.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,12 +1869,12 @@ struct sg_table *iwl_pcie_prep_tso(struct iwl_trans *trans, struct sk_buff *skb,
18691869
unsigned int offset)
18701870
{
18711871
struct sg_table *sgt;
1872-
unsigned int n_segments;
1872+
unsigned int n_segments = skb_shinfo(skb)->nr_frags + 1;
1873+
int orig_nents;
18731874

18741875
if (WARN_ON_ONCE(skb_has_frag_list(skb)))
18751876
return NULL;
18761877

1877-
n_segments = DIV_ROUND_UP(skb->len - offset, skb_shinfo(skb)->gso_size);
18781878
*hdr = iwl_pcie_get_page_hdr(trans,
18791879
hdr_room + __alignof__(struct sg_table) +
18801880
sizeof(struct sg_table) +
@@ -1889,11 +1889,12 @@ struct sg_table *iwl_pcie_prep_tso(struct iwl_trans *trans, struct sk_buff *skb,
18891889
sg_init_table(sgt->sgl, n_segments);
18901890

18911891
/* Only map the data, not the header (it is copied to the TSO page) */
1892-
sgt->orig_nents = skb_to_sgvec(skb, sgt->sgl, offset,
1893-
skb->len - offset);
1894-
if (WARN_ON_ONCE(sgt->orig_nents <= 0))
1892+
orig_nents = skb_to_sgvec(skb, sgt->sgl, offset, skb->len - offset);
1893+
if (WARN_ON_ONCE(orig_nents <= 0))
18951894
return NULL;
18961895

1896+
sgt->orig_nents = orig_nents;
1897+
18971898
/* And map the entire SKB */
18981899
if (dma_map_sgtable(trans->dev, sgt, DMA_TO_DEVICE, 0) < 0)
18991900
return NULL;

0 commit comments

Comments
 (0)