Skip to content

Commit 6caf8a6

Browse files
can: rx-offload: can_rx_offload_queue_tail(): fix error handling, avoid skb mem leak
If the rx-offload skb_queue is full can_rx_offload_queue_tail() will not queue the skb and return with an error. This patch frees the skb in case of a full queue, which brings can_rx_offload_queue_tail() in line with the can_rx_offload_queue_sorted() function, which has been adjusted in the previous patch. The return value is adjusted to -ENOBUFS to better reflect the actual problem. The device stats handling is left to the caller. Fixes: d254586 ("can: rx-offload: Add support for HW fifo based irq offloading") Reported-by: Kurt Van Dijck <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent ca913f1 commit 6caf8a6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/can/rx-offload.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,10 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
252252
struct sk_buff *skb)
253253
{
254254
if (skb_queue_len(&offload->skb_queue) >
255-
offload->skb_queue_len_max)
256-
return -ENOMEM;
255+
offload->skb_queue_len_max) {
256+
kfree_skb(skb);
257+
return -ENOBUFS;
258+
}
257259

258260
skb_queue_tail(&offload->skb_queue, skb);
259261
can_rx_offload_schedule(offload);

0 commit comments

Comments
 (0)