[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4a17d0e2-bed9-43e5-a867-a501b991e6e7@web.de>
Date: Fri, 28 Mar 2025 11:56:41 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: Qasim Ijaz <qasdev00@...il.com>, linux-input@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-stm32@...md-mailman.stormreply.com
Cc: LKML <linux-kernel@...r.kernel.org>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Benjamin Tissoires <bentiss@...nel.org>, Jiri Kosina <jikos@...nel.org>,
Maxime Coquelin <mcoquelin.stm32@...il.com>
Subject: Re: [PATCH] HID: thrustmaster: fix memory leak in
thrustmaster_interrupts()
> 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
Powered by blists - more mailing lists