* [PATCH v6 net] ps3/gelic: Fix SKB allocation
@ 2024-02-21 2:27 Geoff Levand
2024-02-21 17:28 ` Simon Horman
2024-02-23 12:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Geoff Levand @ 2024-02-21 2:27 UTC (permalink / raw)
To: sambat goson, Christophe Leroy, Paolo Abeni, David S. Miller,
Jakub Kicinski, netdev@vger.kernel.org
Commit 3ce4f9c3fbb3 ("net/ps3_gelic_net: Add gelic_descr structures") of
6.8-rc1 had a copy-and-paste error where the pointer that holds the
allocated SKB (struct gelic_descr.skb) was set to NULL after the SKB was
allocated. This resulted in a kernel panic when the SKB pointer was
accessed.
This fix moves the initialization of the gelic_descr to before the SKB
is allocated.
Reported-by: sambat goson <sombat3960@gmail.com>
Fixes: 3ce4f9c3fbb3 ("net/ps3_gelic_net: Add gelic_descr structures")
Signed-off-by: Geoff Levand <geoff@infradead.org>
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index d5b75af163d3..c1b0d35c8d05 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -384,18 +384,18 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE)
dev_info(ctodev(card), "%s: ERROR status\n", __func__);
- descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
- if (!descr->skb) {
- descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */
- return -ENOMEM;
- }
descr->hw_regs.dmac_cmd_status = 0;
descr->hw_regs.result_size = 0;
descr->hw_regs.valid_size = 0;
descr->hw_regs.data_error = 0;
descr->hw_regs.payload.dev_addr = 0;
descr->hw_regs.payload.size = 0;
- descr->skb = NULL;
+
+ descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
+ if (!descr->skb) {
+ descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */
+ return -ENOMEM;
+ }
offset = ((unsigned long)descr->skb->data) &
(GELIC_NET_RXBUF_ALIGN - 1);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v6 net] ps3/gelic: Fix SKB allocation
2024-02-21 2:27 [PATCH v6 net] ps3/gelic: Fix SKB allocation Geoff Levand
@ 2024-02-21 17:28 ` Simon Horman
2024-02-23 12:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-02-21 17:28 UTC (permalink / raw)
To: Geoff Levand
Cc: sambat goson, Christophe Leroy, Paolo Abeni, David S. Miller,
Jakub Kicinski, netdev@vger.kernel.org
On Wed, Feb 21, 2024 at 11:27:29AM +0900, Geoff Levand wrote:
> Commit 3ce4f9c3fbb3 ("net/ps3_gelic_net: Add gelic_descr structures") of
> 6.8-rc1 had a copy-and-paste error where the pointer that holds the
> allocated SKB (struct gelic_descr.skb) was set to NULL after the SKB was
> allocated. This resulted in a kernel panic when the SKB pointer was
> accessed.
>
> This fix moves the initialization of the gelic_descr to before the SKB
> is allocated.
>
> Reported-by: sambat goson <sombat3960@gmail.com>
> Fixes: 3ce4f9c3fbb3 ("net/ps3_gelic_net: Add gelic_descr structures")
> Signed-off-by: Geoff Levand <geoff@infradead.org>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v6 net] ps3/gelic: Fix SKB allocation
2024-02-21 2:27 [PATCH v6 net] ps3/gelic: Fix SKB allocation Geoff Levand
2024-02-21 17:28 ` Simon Horman
@ 2024-02-23 12:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-23 12:00 UTC (permalink / raw)
To: Geoff Levand; +Cc: sombat3960, christophe.leroy, pabeni, davem, kuba, netdev
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Wed, 21 Feb 2024 11:27:29 +0900 you wrote:
> Commit 3ce4f9c3fbb3 ("net/ps3_gelic_net: Add gelic_descr structures") of
> 6.8-rc1 had a copy-and-paste error where the pointer that holds the
> allocated SKB (struct gelic_descr.skb) was set to NULL after the SKB was
> allocated. This resulted in a kernel panic when the SKB pointer was
> accessed.
>
> This fix moves the initialization of the gelic_descr to before the SKB
> is allocated.
>
> [...]
Here is the summary with links:
- [v6,net] ps3/gelic: Fix SKB allocation
https://git.kernel.org/netdev/net/c/b0b1210bc150
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] 3+ messages in thread
end of thread, other threads:[~2024-02-23 12:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-21 2:27 [PATCH v6 net] ps3/gelic: Fix SKB allocation Geoff Levand
2024-02-21 17:28 ` Simon Horman
2024-02-23 12:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).