diff mbox series

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

Message ID 20220201143057.3533830-1-steen.hegelund@microchip.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] net: sparx5: do not refer to skb after passing it on | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 3 blamed authors not CCed: Steen.Hegelund@microchip.com bjarni.jonasson@microchip.com lars.povlsen@microchip.com; 3 maintainers not CCed: Steen.Hegelund@microchip.com bjarni.jonasson@microchip.com lars.povlsen@microchip.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes fail Problems with Fixes tag: 1
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Steen Hegelund Feb. 1, 2022, 2:30 p.m. UTC
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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

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

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

--
2.35.1

Comments

Jakub Kicinski Feb. 2, 2022, 4:05 a.m. UTC | #1
On Tue, 1 Feb 2022 15:30:57 +0100 Steen Hegelund wrote:
> 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:

No need to spell it out, the tags speak for themselves.

> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 

Drop this...

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

and this empty line - all the tags should be together.

> Signed-off-by: Steen Hegelund <steen.hegelund@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++;

sorry to nit pick - wouldn't it be neater if both the stats were
updated together?  Looks a little strange that netif_rx() is in
between the two now.

>  }
> 
> --
> 2.35.1
>
Steen Hegelund Feb. 2, 2022, 8:23 a.m. UTC | #2
Hi Jacub,

Thanks for the feedback.

I will update according to your suggestions.

BR
Steen

On Tue, 2022-02-01 at 20:05 -0800, Jakub Kicinski wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Tue, 1 Feb 2022 15:30:57 +0100 Steen Hegelund wrote:
> > 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:
> 
> No need to spell it out, the tags speak for themselves.
> 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> 
> Drop this...
> 
> > Fixes: f3cad2611a77 (net: sparx5: add hostmode with phylink support)
> > 
> 
> and this empty line - all the tags should be together.
> 
> > Signed-off-by: Steen Hegelund <steen.hegelund@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++;
> 
> sorry to nit pick - wouldn't it be neater if both the stats were
> updated together?  Looks a little strange that netif_rx() is in
> between the two now.
> 
> >  }
> > 
> > --
> > 2.35.1
> > 
>
diff mbox series

Patch

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++;
 }