All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: lan966x: Fix use of pointer after being freed
@ 2022-05-11 20:40 Horatiu Vultur
  2022-05-12 23:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Horatiu Vultur @ 2022-05-11 20:40 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: UNGLinuxDriver, davem, edumazet, kuba, pabeni, Horatiu Vultur,
	Dan Carpenter

The smatch found the following warning:

drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c:736 lan966x_fdma_reload()
warn: 'rx_dcbs' was already freed.

This issue can happen when changing the MTU on one of the ports and once
the RX buffers are allocated and then the TX buffer allocation fails.
In that case the RX buffers should not be restore. This fix this issue
such that the RX buffers will not be restored if the TX buffers failed
to be allocated.

Fixes: 2ea1cbac267e2a ("net: lan966x: Update FDMA to change MTU.")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
index 9e2a7323eaf0..6dea7f8c1481 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
@@ -729,11 +729,11 @@ static int lan966x_fdma_reload(struct lan966x *lan966x, int new_mtu)
 	return err;
 restore:
 	lan966x->rx.dma = rx_dma;
-	lan966x->tx.dma = tx_dma;
+	lan966x->rx.dcbs = rx_dcbs;
 	lan966x_fdma_rx_start(&lan966x->rx);
 
 restore_tx:
-	lan966x->rx.dcbs = rx_dcbs;
+	lan966x->tx.dma = tx_dma;
 	lan966x->tx.dcbs = tx_dcbs;
 	lan966x->tx.dcbs_buf = tx_dcbs_buf;
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: lan966x: Fix use of pointer after being freed
  2022-05-11 20:40 [PATCH net-next] net: lan966x: Fix use of pointer after being freed Horatiu Vultur
@ 2022-05-12 23:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-12 23:40 UTC (permalink / raw)
  To: Horatiu Vultur
  Cc: netdev, linux-kernel, UNGLinuxDriver, davem, edumazet, kuba,
	pabeni, dan.carpenter

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 11 May 2022 22:40:59 +0200 you wrote:
> The smatch found the following warning:
> 
> drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c:736 lan966x_fdma_reload()
> warn: 'rx_dcbs' was already freed.
> 
> This issue can happen when changing the MTU on one of the ports and once
> the RX buffers are allocated and then the TX buffer allocation fails.
> In that case the RX buffers should not be restore. This fix this issue
> such that the RX buffers will not be restored if the TX buffers failed
> to be allocated.
> 
> [...]

Here is the summary with links:
  - [net-next] net: lan966x: Fix use of pointer after being freed
    https://git.kernel.org/netdev/net-next/c/f0a65f815f64

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-12 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 20:40 [PATCH net-next] net: lan966x: Fix use of pointer after being freed Horatiu Vultur
2022-05-12 23:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.