]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
can: rx-offload: can_rx_offload_queue_sorted(): fix error handling, avoid skb mem...
authorMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 9 Oct 2019 13:48:48 +0000 (15:48 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 4 Dec 2019 09:29:26 +0000 (10:29 +0100)
commita2bfc19fa2a47c64c0662b1c817c30aa4b84727f
treee580a26c4a6871e788ba1138f92009dd324d2bfa
parentf5094b0a8d5596391ccc5a57b7ea6b1be6c8dd6d
can: rx-offload: can_rx_offload_queue_sorted(): fix error handling, avoid skb mem leak

BugLink: https://bugs.launchpad.net/bugs/1852338
commit ca913f1ac024559ebc17f0b599af262f0ad997c9 upstream.

If the rx-offload skb_queue is full can_rx_offload_queue_sorted() will
not queue the skb and return with an error.

None of the callers of this function, issue a kfree_skb() to free the
not queued skb. This results in a memory leak.

This patch fixes the problem by freeing the skb in case of a full queue.
The return value is adjusted to -ENOBUFS to better reflect the actual
problem.

The device stats handling is left to the callers, as this function might
be used in both the rx and tx path.

Fixes: 55059f2b7f86 ("can: rx-offload: introduce can_rx_offload_get_echo_skb() and can_rx_offload_queue_sorted() functions")
Cc: linux-stable <stable@vger.kernel.org>
Cc: Martin Hundebøll <martin@geanix.com>
Reported-by: Martin Hundebøll <martin@geanix.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/can/rx-offload.c