diff mbox series

[net,06/13] net: stmmac: Free temporary Rx SKB on request

Message ID 20230313224237.28757-7-Sergey.Semin@baikalelectronics.ru (mailing list archive)
State New, archived
Headers show
Series net: stmmac: Fixes bundle #1 | expand

Commit Message

Serge Semin March 13, 2023, 10:42 p.m. UTC
In case if an incoming frame couldn't be finished in one stmmac_rx()
method call an SKB used to collect data so far will be saved in the
corresponding Rx-queue state buffer. If the network device is closed
before the frame is completed the preserved SKB will be utilized on the
next network interface link uprising cycle right on the first frame
reception, which will cause having a confused set of SKB data. Let's free
the allocated Rx SKB then when all Rx-buffers are requested to be freed.

Fixes: ec222003bd94 ("net: stmmac: Prepare to add Split Header support")
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Piotr Raczynski March 14, 2023, 11:26 a.m. UTC | #1
On Tue, Mar 14, 2023 at 01:42:30AM +0300, Serge Semin wrote:
> In case if an incoming frame couldn't be finished in one stmmac_rx()
> method call an SKB used to collect data so far will be saved in the
> corresponding Rx-queue state buffer. If the network device is closed
> before the frame is completed the preserved SKB will be utilized on the
> next network interface link uprising cycle right on the first frame
> reception, which will cause having a confused set of SKB data. Let's free
> the allocated Rx SKB then when all Rx-buffers are requested to be freed.
> 
> Fixes: ec222003bd94 ("net: stmmac: Prepare to add Split Header support")
> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index ee4297a25521..4d643b1bbf65 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1545,6 +1545,10 @@ static void dma_free_rx_skbufs(struct stmmac_priv *priv,
>  
>  	for (i = 0; i < dma_conf->dma_rx_size; i++)
>  		stmmac_free_rx_buffer(priv, rx_q, i);
> +
> +	if (rx_q->state_saved)
> +		dev_kfree_skb(rx_q->state.skb);
> +	rx_q->state_saved = false;
>  }
>  
>  static int stmmac_alloc_rx_buffers(struct stmmac_priv *priv,
> -- 
> 2.39.2
> 
> 
LGTM, thanks.
Reviewed-by: Piotr Raczynski <piotr.raczynski@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index ee4297a25521..4d643b1bbf65 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1545,6 +1545,10 @@  static void dma_free_rx_skbufs(struct stmmac_priv *priv,
 
 	for (i = 0; i < dma_conf->dma_rx_size; i++)
 		stmmac_free_rx_buffer(priv, rx_q, i);
+
+	if (rx_q->state_saved)
+		dev_kfree_skb(rx_q->state.skb);
+	rx_q->state_saved = false;
 }
 
 static int stmmac_alloc_rx_buffers(struct stmmac_priv *priv,