]> git.sur5r.net Git - u-boot/commitdiff
usb: gadget: pxa25x_udc: fix use-before-initialized bug
authorAlex Sadovsky <nable.maininbox@googlemail.com>
Thu, 8 Jan 2015 17:51:10 +0000 (20:51 +0300)
committerMarek Vasut <marex@denx.de>
Sun, 18 Jan 2015 11:31:01 +0000 (12:31 +0100)
Fix use-before-initialized bug in pxa25x_udc driver.

Function usb_gadget_register_driver calls udc_disable,
and udc_disable calls pullup_off that uses dev->mach->udc_command.
But dev->mach is initialized in usb_gadget_register_driver after
calling udc_disable. This patch fixes the order of initialization.

Signed-off-by: Alex Sadovsky <Nable.MainInbox@googlemail.com>
drivers/usb/gadget/pxa25x_udc.c

index 8945c5b665511b16dc44dd04c240dcbedc0af3b1..d4460b2dc715fe2ca197533aed285ee63fe35f0f 100644 (file)
@@ -1950,11 +1950,11 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        dev->watchdog.period = 5000 * CONFIG_SYS_HZ / 1000000; /* 5 ms */
        dev->watchdog.function = udc_watchdog;
 
+       dev->mach = &mach_info;
+
        udc_disable(dev);
        udc_reinit(dev);
 
-       dev->mach = &mach_info;
-
        dev->gadget.name = "pxa2xx_udc";
        retval = driver->bind(&dev->gadget);
        if (retval) {