can: etas_es58x: es58x_rx_err_msg(): fix memory leak in error path
authorVincent Mailhol <mailhol.vincent@wanadoo.fr>
Tue, 26 Oct 2021 18:07:40 +0000 (03:07 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:17:10 +0000 (19:17 +0100)
commit7eb0881aec26099089f12ae850aebd93190b1dfe
treecd07be74b16de46fe602a08d3408756bd801c1b8
parente16a1e4ba6da1e153878e0ec6c6ae5597b69dfc9
can: etas_es58x: es58x_rx_err_msg(): fix memory leak in error path

[ Upstream commit d9447f768bc8c60623e4bb3ce65b8f4654d33a50 ]

In es58x_rx_err_msg(), if can->do_set_mode() fails, the function
directly returns without calling netif_rx(skb). This means that the
skb previously allocated by alloc_can_err_skb() is not freed. In other
terms, this is a memory leak.

This patch simply removes the return statement in the error branch and
let the function continue.

Issue was found with GCC -fanalyzer, please follow the link below for
details.

Fixes: 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces")
Link: https://lore.kernel.org/all/20211026180740.1953265-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/can/usb/etas_es58x/es58x_core.c