Skip to contentSkip to conversation

usb: gadget: pxa25x_udc: fix use-before-initialized bug

PATCH New Nable 2 participants 6 messages Jan 7, 2015 – Jan 9, 2015 USB

lore
Share & tools
lore

Nable

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/usb/gadget/pxa25x_udc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/pxa25x_udc.c +2 -2
index 8945c5b..d4460b2 100644
@@ -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) {
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 usb: gadget: pxa25x_udc: fix use-before-initialized bug

Quoted 8 lines · Nable

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.

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

author
#2 lore raw

PATCH 1/1 usb: gadget: pxa25x_udc: fix use-before-initialized bug

Hi!

Quoted 1 line

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!

Best regards,
Alex Sadovsky.

#3 lore raw

PATCH 1/1 usb: gadget: pxa25x_udc: fix use-before-initialized bug

Quoted 1 line · Nable

Hi!

Hi!

Quoted 6 lines
Quoted 1 line

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

author
#4 lore raw

PATCH 1/1 usb: gadget: pxa25x_udc: fix use-before-initialized bug

Quoted 4 lines

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.

Quoted 3 lines

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".

Quoted 1 line

[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.

#5 lore raw

PATCH 1/1 usb: gadget: pxa25x_udc: fix use-before-initialized bug

On Thursday, January 08, 2015 at 07:19:35 PM, Nable wrote:

Hi!

Quoted 7 lines
Quoted 4 lines

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!

Quoted 3 lines

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 :)

Quoted 8 lines
Quoted 3 lines

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 :)

Quoted 4 lines
Quoted 1 line

[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