Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
can: rx-offload: can_rx_offload_queue_tail(): fix error handling, avo…
Browse files Browse the repository at this point in the history
…id 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 <dev.kurt@vandijck-laurijssen.be>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
marckleinebudde committed Nov 4, 2019
1 parent ca913f1 commit 6caf8a6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/can/rx-offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
struct sk_buff *skb)
{
if (skb_queue_len(&offload->skb_queue) >
offload->skb_queue_len_max)
return -ENOMEM;
offload->skb_queue_len_max) {
kfree_skb(skb);
return -ENOBUFS;
}

skb_queue_tail(&offload->skb_queue, skb);
can_rx_offload_schedule(offload);
Expand Down

0 comments on commit 6caf8a6

Please sign in to comment.