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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-stmmac-sanitise-stmmac_is_jumbo_frm'

Russell King says:

====================
net: stmmac: sanitise stmmac_is_jumbo_frm()

stmmac_is_jumbo_frm() takes skb->len, which is unsigned int, but the
parameter is passed as an "int" and then tested using signed
comparisons. This can cause bugs. Change the parameter to be unsigned.

Also arrange for it to return a bool.
====================

Link: https://patch.msgid.link/aRxDqJSWxOdOaRt4@shell.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+10 -16
+4 -5
drivers/net/ethernet/stmicro/stmmac/chain_mode.c
··· 83 83 return entry; 84 84 } 85 85 86 - static unsigned int is_jumbo_frm(int len, int enh_desc) 86 + static bool is_jumbo_frm(unsigned int len, bool enh_desc) 87 87 { 88 - unsigned int ret = 0; 88 + bool ret = false; 89 89 90 90 if ((enh_desc && (len > BUF_SIZE_8KiB)) || 91 - (!enh_desc && (len > BUF_SIZE_2KiB))) { 92 - ret = 1; 93 - } 91 + (!enh_desc && (len > BUF_SIZE_2KiB))) 92 + ret = true; 94 93 95 94 return ret; 96 95 }
+1 -1
drivers/net/ethernet/stmicro/stmmac/hwif.h
··· 541 541 struct stmmac_mode_ops { 542 542 void (*init) (void *des, dma_addr_t phy_addr, unsigned int size, 543 543 unsigned int extend_desc); 544 - unsigned int (*is_jumbo_frm) (int len, int ehn_desc); 544 + bool (*is_jumbo_frm)(unsigned int len, bool enh_desc); 545 545 int (*jumbo_frm)(struct stmmac_tx_queue *tx_q, struct sk_buff *skb, 546 546 int csum); 547 547 int (*set_16kib_bfsize)(int mtu);
+2 -7
drivers/net/ethernet/stmicro/stmmac/ring_mode.c
··· 91 91 return entry; 92 92 } 93 93 94 - static unsigned int is_jumbo_frm(int len, int enh_desc) 94 + static bool is_jumbo_frm(unsigned int len, bool enh_desc) 95 95 { 96 - unsigned int ret = 0; 97 - 98 - if (len >= BUF_SIZE_4KiB) 99 - ret = 1; 100 - 101 - return ret; 96 + return len >= BUF_SIZE_4KiB; 102 97 } 103 98 104 99 static void refill_desc3(struct stmmac_rx_queue *rx_q, struct dma_desc *p)
+3 -3
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 4583 4583 */ 4584 4584 static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) 4585 4585 { 4586 - unsigned int first_entry, tx_packets, enh_desc; 4586 + bool enh_desc, has_vlan, set_ic, is_jumbo = false; 4587 4587 struct stmmac_priv *priv = netdev_priv(dev); 4588 4588 unsigned int nopaged_len = skb_headlen(skb); 4589 - int i, csum_insertion = 0, is_jumbo = 0; 4590 4589 u32 queue = skb_get_queue_mapping(skb); 4591 4590 int nfrags = skb_shinfo(skb)->nr_frags; 4591 + unsigned int first_entry, tx_packets; 4592 4592 int gso = skb_shinfo(skb)->gso_type; 4593 4593 struct stmmac_txq_stats *txq_stats; 4594 4594 struct dma_edesc *tbs_desc = NULL; 4595 4595 struct dma_desc *desc, *first; 4596 4596 struct stmmac_tx_queue *tx_q; 4597 - bool has_vlan, set_ic; 4597 + int i, csum_insertion = 0; 4598 4598 int entry, first_tx; 4599 4599 dma_addr_t des; 4600 4600 u32 sdu_len;