[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221120101414.6071-1-niejianglei2021@163.com>
Date: Sun, 20 Nov 2022 18:14:14 +0800
From: Jianglei Nie <niejianglei2021@....com>
To: yashi@...cecubics.com, wg@...ndegger.com, mkl@...gutronix.de,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, mailhol.vincent@...adoo.fr,
stefan.maetje@....eu, socketcan@...tkopp.net, hbh25y@...il.com
Cc: linux-can@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Jianglei Nie <niejianglei2021@....com>
Subject: [PATCH] can: mcba_usb: fix potential resource leak in mcba_usb_xmit_cmd()
mcba_usb_xmit_cmd() gets free ctx by mcba_usb_get_free_ctx(). When
mcba_usb_xmit() fails, the ctx should be freed with mcba_usb_free_ctx()
like mcba_usb_start_xmit() does in label "xmit_failed" to avoid potential
resource leak.
Fix it by calling mcba_usb_free_ctx() when mcba_usb_xmit() fails.
Signed-off-by: Jianglei Nie <niejianglei2021@....com>
---
drivers/net/can/usb/mcba_usb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c
index 218b098b261d..471f6be6e030 100644
--- a/drivers/net/can/usb/mcba_usb.c
+++ b/drivers/net/can/usb/mcba_usb.c
@@ -380,9 +380,11 @@ static void mcba_usb_xmit_cmd(struct mcba_priv *priv,
}
err = mcba_usb_xmit(priv, usb_msg, ctx);
- if (err)
+ if (err) {
+ mcba_usb_free_ctx(ctx);
netdev_err(priv->netdev, "Failed to send cmd (%d)",
usb_msg->cmd_id);
+ }
}
static void mcba_usb_xmit_change_bitrate(struct mcba_priv *priv, u16 bitrate)
--
2.25.1
Powered by blists - more mailing lists