Skip to content

Commit b0b1210

Browse files
glevanddavem330
authored andcommitted
ps3/gelic: Fix SKB allocation
Commit 3ce4f9c ("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 <[email protected]> Fixes: 3ce4f9c ("net/ps3_gelic_net: Add gelic_descr structures") Signed-off-by: Geoff Levand <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 734f06d commit b0b1210

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/net/ethernet/toshiba/ps3_gelic_net.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,18 +384,18 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
384384
if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE)
385385
dev_info(ctodev(card), "%s: ERROR status\n", __func__);
386386

387-
descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
388-
if (!descr->skb) {
389-
descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */
390-
return -ENOMEM;
391-
}
392387
descr->hw_regs.dmac_cmd_status = 0;
393388
descr->hw_regs.result_size = 0;
394389
descr->hw_regs.valid_size = 0;
395390
descr->hw_regs.data_error = 0;
396391
descr->hw_regs.payload.dev_addr = 0;
397392
descr->hw_regs.payload.size = 0;
398-
descr->skb = NULL;
393+
394+
descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
395+
if (!descr->skb) {
396+
descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */
397+
return -ENOMEM;
398+
}
399399

400400
offset = ((unsigned long)descr->skb->data) &
401401
(GELIC_NET_RXBUF_ALIGN - 1);

0 commit comments

Comments
 (0)