usb: musb: musb_gadget: fix resource leakage in error path
authorRahul Ruikar <rahul.ruikar@gmail.com>
Sat, 2 Oct 2010 06:35:48 +0000 (01:35 -0500)
committerFelipe Balbi <balbi@ti.com>
Fri, 5 Nov 2010 11:43:14 +0000 (13:43 +0200)
In function musb_gadget_setup() call put_device()
when device_register() fails.

Signed-off-by: Rahul Ruikar <rahul.ruikar@gmail.com>
Acked-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/musb/musb_gadget.c

index ce31f079b31e4f4d0969858bbaf551cb4eca4498..ba22e4a20f9537d560b5bd21e041276b32bfaa5c 100644 (file)
@@ -1705,8 +1705,10 @@ int __init musb_gadget_setup(struct musb *musb)
        musb_platform_try_idle(musb, 0);
 
        status = device_register(&musb->g.dev);
-       if (status != 0)
+       if (status != 0) {
+               put_device(&musb->g.dev);
                the_gadget = NULL;
+       }
        return status;
 }