Skip to contentSkip to conversation

ps3/gelic: Fix SKB allocation

PATCH Applied Geoff Levand 3 participants 3 messages Feb 21, 2024 – Feb 23, 2024

Subsystems (4)
lore
Share & tools
lore

Geoff Levand

author maintainer
#0 lore raw

PATCH v6 1/1 ps3/gelic: Fix SKB allocation

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.

Fixes 3ce4f9c3fbb3 ("net/ps3_gelic_net: Add gelic_descr structures")
drivers/net/ethernet/toshiba/ps3_gelic_net.c +6 -6
index d5b75af163d3..c1b0d35c8d05 100644
@@ -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);
reviewer Reviewed-by on v6 1/1
#1 lore raw
Quoted 6 lines · Geoff Levand

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.

Quoted 6 lines

This fix moves the initialization of the gelic_descr to before the SKB is allocated.

Fixes 3ce4f9c3fbb3 ("net/ps3_gelic_net: Add gelic_descr structures")
#2 lore raw
In reply to Geoff Levand
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 10 lines · 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html