Skip to content

Commit 50aca89

Browse files
vincent-mailholmarckleinebudde
authored andcommitted
can: peak_usb: fix use after free bugs
After calling peak_usb_netif_rx_ni(skb), dereferencing skb is unsafe. Especially, the can_frame cf which aliases skb memory is accessed after the peak_usb_netif_rx_ni(). Reordering the lines solves the issue. Fixes: 0a25e1f ("can: peak_usb: add support for PEAK new CANFD USB adapters") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vincent Mailhol <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 75854ca commit 50aca89

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/can/usb/peak_usb/pcan_usb_fd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,11 @@ static int pcan_usb_fd_decode_canmsg(struct pcan_usb_fd_if *usb_if,
514514
else
515515
memcpy(cfd->data, rm->d, cfd->len);
516516

517-
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));
518-
519517
netdev->stats.rx_packets++;
520518
netdev->stats.rx_bytes += cfd->len;
521519

520+
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));
521+
522522
return 0;
523523
}
524524

@@ -580,11 +580,11 @@ static int pcan_usb_fd_decode_status(struct pcan_usb_fd_if *usb_if,
580580
if (!skb)
581581
return -ENOMEM;
582582

583-
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));
584-
585583
netdev->stats.rx_packets++;
586584
netdev->stats.rx_bytes += cf->len;
587585

586+
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));
587+
588588
return 0;
589589
}
590590

0 commit comments

Comments
 (0)