[PATCH net] net: sparx5: do not refer to skb after passing it on

Steen Hegelund steen.hegelund at microchip.com
Tue Feb 1 06:30:57 PST 2022


Do not try to use any SKB fields after the packet has been passed up in the
receive stack.

This error was reported as shown below:
Reported-by: kernel test robot <lkp at intel.com>
Reported-by: Dan Carpenter <dan.carpenter at oracle.com>

Fixes: f3cad2611a77 (net: sparx5: add hostmode with phylink support)

Signed-off-by: Steen Hegelund <steen.hegelund at microchip.com>
---
 drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
index dc7e5ea6ec15..ebdce4b35686 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
@@ -145,8 +145,8 @@ static void sparx5_xtr_grp(struct sparx5 *sparx5, u8 grp, bool byte_swap)
 	skb_put(skb, byte_cnt - ETH_FCS_LEN);
 	eth_skb_pad(skb);
 	skb->protocol = eth_type_trans(skb, netdev);
-	netif_rx(skb);
 	netdev->stats.rx_bytes += skb->len;
+	netif_rx(skb);
 	netdev->stats.rx_packets++;
 }

--
2.35.1




More information about the linux-arm-kernel mailing list