From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org, linux-can <linux-can@vger.kernel.org>
Cc: davem@davemloft.net, kernel@pengutronix.de,
jhofstee@victronenergy.com,
"Martin Hundebøll" <martin@geanix.com>,
"Kurt Van Dijck" <dev.kurt@vandijck-laurijssen.be>,
"Marc Kleine-Budde" <mkl@pengutronix.de>
Subject: [PATCH 13/29] can: rx-offload: can_rx_offload_queue_tail(): fix error handling, avoid skb mem leak
Date: Thu, 10 Oct 2019 14:17:34 +0200 [thread overview]
Message-ID: <20191010121750.27237-14-mkl@pengutronix.de> (raw)
In-Reply-To: <20191010121750.27237-1-mkl@pengutronix.de>
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: d254586c3453 ("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>
---
drivers/net/can/rx-offload.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
index 663697439d1c..d1c863409945 100644
--- a/drivers/net/can/rx-offload.c
+++ b/drivers/net/can/rx-offload.c
@@ -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);
--
2.23.0
next prev parent reply other threads:[~2019-10-10 12:18 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 12:17 linux-can/testing: Request for testing Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 01/29] can: dev: add missing of_node_put() after calling of_get_child_by_name() Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 02/29] can: gs_usb: gs_can_open(): prevent memory leak Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 03/29] can: mcba_usb: fix use-after-free on disconnect Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 04/29] can: usb_8dev: " Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 05/29] can: flexcan: disable completely the ECC mechanism Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 06/29] can: peak_usb: fix a potential out-of-sync while decoding packets Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 07/29] can: peak_usb: report bus recovery as well Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 08/29] can: c_can: c_can_poll(): only read status register after status IRQ Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 09/29] can: c_can: D_CAN: c_can_chip_config(): perform a sofware reset on open Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 10/29] can: c_can: C_CAN: add bus recovery events Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 11/29] can: xilinx_can: Fix flags field initialization for axi can Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 12/29] can: rx-offload: can_rx_offload_queue_sorted(): fix error handling, avoid skb mem leak Marc Kleine-Budde
2019-10-10 12:17 ` Marc Kleine-Budde [this message]
2019-10-10 12:17 ` [PATCH 14/29] can: rx-offload: can_rx_offload_offload_one(): do not increase the skb_queue beyond skb_queue_len_max Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 15/29] can: rx-offload: can_rx_offload_offload_one(): increment rx_fifo_errors on queue overflow or OOM Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 16/29] can: rx-offload: can_rx_offload_offload_one(): use ERR_PTR() to propagate error value in case of errors Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 17/29] can: rx-offload: can_rx_offload_irq_offload_timestamp(): continue on error Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 18/29] can: rx-offload: can_rx_offload_irq_offload_fifo(): " Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 19/29] can: flexcan: increase error counters if skb enqueueing via can_rx_offload_queue_sorted() fails Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 20/29] can: ti_hecc: ti_hecc_error(): " Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 21/29] can: ti_hecc: ti_hecc_stop(): stop the CPK on down Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 22/29] can: ti_hecc: keep MIM and MD set Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 23/29] can: ti_hecc: release the mailbox a bit earlier Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 24/29] can: ti_hecc: add fifo underflow error reporting Marc Kleine-Budde
2019-10-10 15:52 ` Marc Kleine-Budde
2019-10-10 18:04 ` Jeroen Hofstee
[not found] ` <694ef4e8-166b-7eeb-4d6e-39a0ecacc93f@victronenergy.com>
2019-10-10 20:29 ` Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 25/29] can: ti_hecc: properly report state changes Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 26/29] can: ti_hecc: add missing " Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 27/29] can: j1939: fix resource leak of skb on error return paths Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 28/29] can: j1939: fix memory leak if filters was set Marc Kleine-Budde
2019-10-10 12:17 ` [PATCH 29/29] can: don't use deprecated license identifiers Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191010121750.27237-14-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=davem@davemloft.net \
--cc=dev.kurt@vandijck-laurijssen.be \
--cc=jhofstee@victronenergy.com \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=martin@geanix.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).