RE: Re: Subject: [PATCH v1] USB:Core: BugFix: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously

From: Ajay Kaher
Date: Tue Jan 31 2017 - 00:55:23 EST



Â
At boot time, probe function of multiple connected devices
(proprietary devices) execute simultaneously. And because
of the following code path race condition happens:
probe->usb_register_dev->init_usb_class

Tested with these changes, and problem has been solved.

thanks,
ajay kaher


--------- Original Message ---------
Sender : gregkh@xxxxxxxxxxxxxxxxxxxÂ<gregkh@xxxxxxxxxxxxxxxxxxx>
Date : 2017-01-30 14:36 (GMT+5:30)
Title : Re: Subject: [PATCH v1] USB:Core: BugFix: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously
Â
OnÂMon,ÂJanÂ30,Â2017ÂatÂ08:25:25AMÂ+0000,ÂAjayÂKaherÂwrote:
>ÂÂ
Â
FirstÂoff,ÂyouÂareÂsendingÂhtmlÂemail,ÂwhichÂtheÂmailingÂlistÂkeeps
rejecting,ÂwhyÂareÂyouÂignoringÂthat?
Â
Â
Â
>Â
>ÂThereÂisÂraceÂconditionÂwhenÂtwoÂUSBÂclassÂdriversÂtryÂtoÂcall
>Â
>Âinit_usb_classÂatÂtheÂsameÂtimeÂandÂleadsÂtoÂcrash.
>Â
>ÂÂ
>Â
>ÂTheÂmainÂreasonÂforÂthisÂisÂoneÂofÂtheÂClassÂdriversÂallocatesÂmemory
>ÂforÂusb_classÂstructureÂandÂinitializesÂitsÂmember.ÂInÂtheÂmeantimeÂNULL
>ÂcheckÂforÂusb_classÂstructureÂfailsÂandÂassumesÂthatÂusb_classÂstructure
>ÂisÂproperlyÂinitializedÂandÂcrashedÂwhileÂtryingÂtoÂaccessÂitsÂmembers.
>Â
>ÂÂ
>Â
>ÂToÂavoidÂthisÂraceÂconditionÂlockingÂrequiredÂbeforeÂcalling
>Âinit_usb_classÂfromÂfunctionÂusb_register_dev.
>Â
>ÂÂ
>Â
>ÂÂ
>Â
>ÂSigned-off-by:ÂAjayÂKaher
Â
DoesÂthisÂlookÂcorrect?ÂÂPleaseÂworkÂwithÂsomeÂofÂtheÂsamsungÂkernel
developersÂforÂhowÂtoÂproperlyÂsubmitÂaÂpatch.
Â
AndÂfinally,ÂhowÂareÂtwoÂdriversÂcallingÂinit_usb_class()ÂatÂtheÂsame
time?ÂÂWhatÂcodeÂpathÂcausesÂthat?ÂÂHaveÂyouÂseenÂthisÂhappen,ÂandÂif
so,ÂwhatÂdriversÂcausedÂit?
Â
thanks,
Â
gregÂk-h
Â
Â