From: Markus Elfring <Markus.Elfring@web.de>
To: Qasim Ijaz <qasdev00@gmail.com>,
linux-input@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com
Cc: LKML <linux-kernel@vger.kernel.org>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Benjamin Tissoires <bentiss@kernel.org>,
Jiri Kosina <jikos@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>
Subject: Re: [PATCH] HID: thrustmaster: fix memory leak in thrustmaster_interrupts()
Date: Fri, 28 Mar 2025 11:56:41 +0100 [thread overview]
Message-ID: <4a17d0e2-bed9-43e5-a867-a501b991e6e7@web.de> (raw)
In-Reply-To: <20250327231146.6388-1-qasdev00@gmail.com>
> In thrustmaster_interrupts(), the allocated send_buf is not
> freed if the usb_check_int_endpoints() check fails, leading
> to a memory leak.
…
I imagine that word wrapping can occasionally become a bit nicer
for text lines which may be longer than 59 characters.
…
> +++ b/drivers/hid/hid-thrustmaster.c
> @@ -174,6 +174,7 @@ static void thrustmaster_interrupts(struct hid_device *hdev)
> u8 ep_addr[2] = {b_ep, 0};
>
> if (!usb_check_int_endpoints(usbif, ep_addr)) {
> + kfree(send_buf);
> hid_err(hdev, "Unexpected non-int endpoint\n");
> return;
> }
* You may avoid such repeated function calls by using another label instead.
https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources#MEM12C.Considerusingagotochainwhenleavingafunctiononerrorwhenusingandreleasingresources-CompliantSolution(copy_process()fromLinuxkernel)
* How do you think about to benefit any more from the application of the attribute “__free”?
https://elixir.bootlin.com/linux/v6.14-rc6/source/include/linux/cleanup.h#L144
Regards,
Markus
next prev parent reply other threads:[~2025-03-28 10:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 23:11 [PATCH] HID: thrustmaster: fix memory leak in thrustmaster_interrupts() Qasim Ijaz
2025-03-28 10:56 ` Markus Elfring [this message]
2025-04-24 9:48 ` Jiri Kosina
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=4a17d0e2-bed9-43e5-a867-a501b991e6e7@web.de \
--to=markus.elfring@web.de \
--cc=alexandre.torgue@foss.st.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=qasdev00@gmail.com \
/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).