[U-Boot] [PATCH] usb: gadget: pxa25x_udc: fix use-before-initialized bug

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: Nable Nable.MainInbox@googlemail.com --- drivers/usb/gadget/pxa25x_udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index 8945c5b..d4460b2 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c @@ -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) {

On Wednesday, January 07, 2015 at 07:23:52 PM, Nable wrote:
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: Nable Nable.MainInbox@googlemail.com
Hi!
Can you please fix From: and Signed-off-by: fields so that they reflect a real person (you) ? Otherwise I'm happy you sent the fix and I'll pick the fixed version.
Thanks!
Best regards, Marek Vasut

On Thursday, January 08, 2015 at 09:38:45 AM, Nable wrote:
Hi!
Hi!
Can you please fix From: and Signed-off-by: fields
Oh, it looks like I have to accept this requirement. Ok, I'll fix it. Should I also change tag in subject to '[PATCH v2]' in a fixed patch?
Thank you for kind answer!
You can use [PATCH RESEND], which is probably much clearer in expressing the intent. You might add a short note just before the diffstat saying that you only updated the SoB line and author to match the real deal, but didn't change the patch contents.
You can read [1] for the finer points of patch submission process, but TL;DR it's pretty much the same as Linux ;-)
[1] http://www.denx.de/wiki/U-Boot/Patches#General_Patch_Submission_Rules
Thank you!
Best regards, Marek Vasut

You can use [PATCH RESEND], which is probably much clearer in expressing the intent. You might add a short note just before the diffstat saying that you only updated the SoB line and author to match the real deal, but didn't change the patch contents.
I've edited my patch and it's still applies on to top HEAD of master branch, so I've sent fixed version to mailing list. Thank you for mentioning this idea of commentaries before diffstat output, I've never heard about it.
You can read [1] for the finer points of patch submission process, but TL;DR it's pretty much the same as Linux ;-)
Sounds like a nice joke! In fact, I'm doing my first steps in open-source software, so sending patches to Linux is something like a far dream. But if I reach that stage someday, then I'll be able to say that it's "pretty much the same as for U-Boot".
[1] http://www.denx.de/wiki/U-Boot/Patches#General_Patch_Submission_Rules
I've studied [1] yesterday, and looked through it again today, so I hope that I'm doing everything in a right way this time.
Best regards, Alex.

On Thursday, January 08, 2015 at 07:19:35 PM, Nable wrote:
Hi!
You can use [PATCH RESEND], which is probably much clearer in expressing the intent. You might add a short note just before the diffstat saying that you only updated the SoB line and author to match the real deal, but didn't change the patch contents.
I've edited my patch and it's still applies on to top HEAD of master branch, so I've sent fixed version to mailing list.
Thanks!
Thank you for mentioning this idea of commentaries before diffstat output, I've never heard about it.
It's mostly useful to save reviewers the time figuring out what changed in the patch and such message never propagates into the applied patch in the tree :)
You can read [1] for the finer points of patch submission process, but TL;DR it's pretty much the same as Linux ;-)
Sounds like a nice joke! In fact, I'm doing my first steps in open-source software, so sending patches to Linux is something like a far dream. But if I reach that stage someday, then I'll be able to say that it's "pretty much the same as for U-Boot".
Heh, everyone's been there at some point. Good luck and have fun :)
[1] http://www.denx.de/wiki/U-Boot/Patches#General_Patch_Submission_Rules
I've studied [1] yesterday, and looked through it again today, so I hope that I'm doing everything in a right way this time.
Yeah, no worries. You'll quickly get the hang of it and someone will remind you in case you screw up bigtime anyway ;-)
Best regards, Marek Vasut
participants (2)
-
Marek Vasut
-
Nable