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 Rejected
Delegated to: Netdev Maintainers
Headers show
Series net: stmmac: Fixes bundle #1 | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers warning 3 maintainers not CCed: linux-mediatek@lists.infradead.org angelogioacchino.delregno@collabora.com matthias.bgg@gmail.com
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

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,