[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191001104428.welkedinv7322tq4@pengutronix.de>
Date: Tue, 1 Oct 2019 12:44:28 +0200
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: Colin King <colin.king@...onical.com>
Cc: Robin van der Gracht <robin@...tonic.nl>,
Oleksij Rempel <linux@...pel-privat.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Oliver Hartkopp <socketcan@...tkopp.net>,
Marc Kleine-Budde <mkl@...gutronix.de>,
"David S . Miller" <davem@...emloft.net>,
linux-can@...r.kernel.org, netdev@...r.kernel.org,
kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][next] can: fix resource leak of skb on error return paths
On Wed, Sep 18, 2019 at 11:11:56AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@...onical.com>
>
> Currently the error return paths do not free skb and this results
> in a memory leak. Fix this by freeing them before the return.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
Acked-by: Oleksij Rempel <o.rempel@...gutronix.de>
> ---
> net/can/j1939/socket.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
> index 37c1040bcb9c..5c6eabcb5df1 100644
> --- a/net/can/j1939/socket.c
> +++ b/net/can/j1939/socket.c
> @@ -909,8 +909,10 @@ void j1939_sk_errqueue(struct j1939_session *session,
> memset(serr, 0, sizeof(*serr));
> switch (type) {
> case J1939_ERRQUEUE_ACK:
> - if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK))
> + if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK)) {
> + kfree_skb(skb);
> return;
> + }
>
> serr->ee.ee_errno = ENOMSG;
> serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING;
> @@ -918,8 +920,10 @@ void j1939_sk_errqueue(struct j1939_session *session,
> state = "ACK";
> break;
> case J1939_ERRQUEUE_SCHED:
> - if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_SCHED))
> + if (!(sk->sk_tsflags & SOF_TIMESTAMPING_TX_SCHED)) {
> + kfree_skb(skb);
> return;
> + }
>
> serr->ee.ee_errno = ENOMSG;
> serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING;
> --
> 2.20.1
>
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Powered by blists - more mailing lists