* [PATCH v2] usb: gadget: r8a66597-udc: Fix double free in r8a66597_probe
@ 2024-09-23 20:20 Mikhail Arkhipov
2024-09-26 8:22 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 2+ messages in thread
From: Mikhail Arkhipov @ 2024-09-23 20:20 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Mikhail Arkhipov, Uwe Kleine-König, Felipe Balbi,
Mike Frysinger, Sebastian Andrzej Siewior, linux-usb,
linux-kernel, lvc-project
The function r8a66597_free_request is already called in the err_add_udc
block, and freeing r8a66597->ep0_req twice may lead to a double free error.
If the probe process fails and the r8a66597_probe function subsequently
goes through its error handling path. Since r8a66597_free_request is called
multiple times in different error handling sections, it leads to an attempt
to free the same memory twice.
Remove the redundant call to r8a66597_free_request in the clean_up2 block.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 0f91349b89f3 ("usb: gadget: convert all users to the new udc infrastructure")
Signed-off-by: Mikhail Arkhipov <m.arhipov@rosa.ru>
---
v2: Remove redundant call to r8a66597_free_request in clean_up2 block
instead of assigning r8a66597->ep0_req to NULL, as suggested by
Sebastian Andrzej Siewior <bigeasy@linutronix.de>.
drivers/usb/gadget/udc/r8a66597-udc.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
index db4a10a979f9..a9b82f371abb 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -1956,9 +1956,6 @@ static int r8a66597_probe(struct platform_device *pdev)
if (r8a66597->pdata->on_chip)
clk_disable_unprepare(r8a66597->clk);
- if (r8a66597->ep0_req)
- r8a66597_free_request(&r8a66597->ep[0].ep, r8a66597->ep0_req);
-
return ret;
}
--
2.39.3 (Apple Git-146)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] usb: gadget: r8a66597-udc: Fix double free in r8a66597_probe
2024-09-23 20:20 [PATCH v2] usb: gadget: r8a66597-udc: Fix double free in r8a66597_probe Mikhail Arkhipov
@ 2024-09-26 8:22 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-09-26 8:22 UTC (permalink / raw)
To: Mikhail Arkhipov
Cc: Greg Kroah-Hartman, Uwe Kleine-König, Felipe Balbi,
Mike Frysinger, linux-usb, linux-kernel, lvc-project
On 2024-09-23 23:20:19 [+0300], Mikhail Arkhipov wrote:
> The function r8a66597_free_request is already called in the err_add_udc
> block, and freeing r8a66597->ep0_req twice may lead to a double free error.
>
> If the probe process fails and the r8a66597_probe function subsequently
> goes through its error handling path. Since r8a66597_free_request is called
> multiple times in different error handling sections, it leads to an attempt
> to free the same memory twice.
>
> Remove the redundant call to r8a66597_free_request in the clean_up2 block.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 0f91349b89f3 ("usb: gadget: convert all users to the new udc infrastructure")
> Signed-off-by: Mikhail Arkhipov <m.arhipov@rosa.ru>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Sebastian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-26 8:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-23 20:20 [PATCH v2] usb: gadget: r8a66597-udc: Fix double free in r8a66597_probe Mikhail Arkhipov
2024-09-26 8:22 ` Sebastian Andrzej Siewior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®