From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756380AbdJJNkI (ORCPT ); Tue, 10 Oct 2017 09:40:08 -0400 Received: from esa6.dell-outbound.iphmx.com ([68.232.149.229]:47394 "EHLO esa6.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755688AbdJJNkG (ORCPT ); Tue, 10 Oct 2017 09:40:06 -0400 From: X-LoopCount0: from 10.166.132.169 X-IronPort-AV: E=Sophos;i="5.42,505,1500958800"; d="scan'208";a="158591207" X-DLP: DLP_GlobalPCIDSS To: CC: , , , , , , , , , Subject: RE: [PATCH v6 05/14] platform/x86: dell-wmi-descriptor: split WMI descriptor into it's own driver Thread-Topic: [PATCH v6 05/14] platform/x86: dell-wmi-descriptor: split WMI descriptor into it's own driver Thread-Index: AQHTQaBLWYSJLt4L102XptELIvbH6aLdFV7A Date: Tue, 10 Oct 2017 13:40:04 +0000 Message-ID: <598ee368fe6b4c4d8217caa63913376f@ausx13mpc120.AMER.DELL.COM> References: <92fb25a14fbc24541cd758854b70268b3497d913.1507589249.git.mario.limonciello@dell.com> <20171010081749.7ohuyadwsg555cli@pali> In-Reply-To: <20171010081749.7ohuyadwsg555cli@pali> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.143.18.86] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v9ADeurP012628 > -----Original Message----- > From: Pali Rohár [mailto:pali.rohar@gmail.com] > Sent: Tuesday, October 10, 2017 3:18 AM > To: Limonciello, Mario > Cc: dvhart@infradead.org; Andy Shevchenko ; > LKML ; platform-driver-x86@vger.kernel.org; > Andy Lutomirski ; quasisec@google.com; rjw@rjwysocki.net; > mjg59@google.com; hch@lst.de; Greg KH > Subject: Re: [PATCH v6 05/14] platform/x86: dell-wmi-descriptor: split WMI > descriptor into it's own driver > > On Monday 09 October 2017 17:51:43 Mario Limonciello wrote: > > +bool dell_wmi_get_interface_version(u32 *version) > > +{ > > + struct descriptor_priv *priv; > > + > > + priv = list_first_entry_or_null(&wmi_list, > > + struct descriptor_priv, > > + list); > > + if (!priv) > > + return false; > > This introduce race condition. In case callee of this function is > executed before binding 8D9DDCBC-A997-11DA-B012-B622A1EF5492 WMI device > into this dell-wmi-descriptor driver, then this function > dell_wmi_get_interface_version() returns false. Even it is running on > supported machine. > > Loading of modulus and also binding devices to drivers (registered by > modules) is is asynchronous. > I suppose you're right, module dependency ordering doesn't necessarily guarantee binding. I'll add in some deferred probing and binding checking. > In case everything is linked into vmlinux binary, this problem could > happen too. Binding & initialization of WMI device to this driver can be > postponed and callee (dell-wmi) would get false. > > > + *version = priv->interface_version; > > + return true; > > +} > > +EXPORT_SYMBOL_GPL(dell_wmi_get_interface_version); > > + > > +bool dell_wmi_get_size(u32 *size) > > +{ > > + struct descriptor_priv *priv; > > + > > + priv = list_first_entry_or_null(&wmi_list, > > + struct descriptor_priv, > > + list); > > + if (!priv) > > + return false; > > And same there. > > > + *size = priv->size; > > + return true; > > +} > > +EXPORT_SYMBOL_GPL(dell_wmi_get_size); > > -- > Pali Rohár > pali.rohar@gmail.com