From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752699AbdA3JGy (ORCPT ); Mon, 30 Jan 2017 04:06:54 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57504 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752676AbdA3JGr (ORCPT ); Mon, 30 Jan 2017 04:06:47 -0500 Date: Mon, 30 Jan 2017 10:06:36 +0100 From: "gregkh@linuxfoundation.org" To: Ajay Kaher Cc: "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , AMAN DEEP , HEMANSHU SRIVASTAVA Subject: Re: Subject: [PATCH v1] USB:Core: BugFix: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously Message-ID: <20170130090636.GA29062@kroah.com> References: <20170130082525epcms5p5e2459e715ebb80cef1574946e3f6ffbf@epcms5p5> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170130082525epcms5p5e2459e715ebb80cef1574946e3f6ffbf@epcms5p5> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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