usb: gadget: fix potential double-free in m66592_probe.
authorQiushi Wu <wu000273@umn.edu>
Sat, 23 May 2020 04:06:25 +0000 (23:06 -0500)
committerFelipe Balbi <balbi@kernel.org>
Mon, 25 May 2020 08:09:43 +0000 (11:09 +0300)
m66592_free_request() is called under label "err_add_udc"
and "clean_up", and m66592->ep0_req is not set to NULL after
first free, leading to a double-free. Fix this issue by
setting m66592->ep0_req to NULL after the first free.

Fixes: 0f91349b89f3 ("usb: gadget: convert all users to the new udc infrastructure")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
drivers/usb/gadget/udc/m66592-udc.c

index 75d16a8902e6dbdd4ac5bf92e09a946b75a76605..931e6362a13dace085b8310d311301f4d91d7c02 100644 (file)
@@ -1667,7 +1667,7 @@ static int m66592_probe(struct platform_device *pdev)
 
 err_add_udc:
        m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
-
+       m66592->ep0_req = NULL;
 clean_up3:
        if (m66592->pdata->on_chip) {
                clk_disable(m66592->clk);