Commit 6caf8a6d authored by Marc Kleine-Budde's avatar Marc Kleine-Budde

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: d254586c ("can: rx-offload: Add support for HW fifo based irq offloading")
Reported-by: default avatarKurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent ca913f1a
...@@ -252,8 +252,10 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload, ...@@ -252,8 +252,10 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
struct sk_buff *skb) struct sk_buff *skb)
{ {
if (skb_queue_len(&offload->skb_queue) > if (skb_queue_len(&offload->skb_queue) >
offload->skb_queue_len_max) offload->skb_queue_len_max) {
return -ENOMEM; kfree_skb(skb);
return -ENOBUFS;
}
skb_queue_tail(&offload->skb_queue, skb); skb_queue_tail(&offload->skb_queue, skb);
can_rx_offload_schedule(offload); can_rx_offload_schedule(offload);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment