From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751498AbbEXQ0S (ORCPT ); Sun, 24 May 2015 12:26:18 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:32833 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751072AbbEXQ0R (ORCPT ); Sun, 24 May 2015 12:26:17 -0400 Date: Sun, 24 May 2015 09:26:16 -0700 From: Greg Kroah-Hartman To: Lu Baolu Cc: Heikki Krogerus , Sasha Levin , David Cohen , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] usb: ulpi: don't register drivers if bus doesn't exist Message-ID: <20150524162616.GB2150@kroah.com> References: <1432198672-384-1-git-send-email-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1432198672-384-1-git-send-email-baolu.lu@linux.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 21, 2015 at 04:57:52PM +0800, Lu Baolu wrote: > ULPI registers its bus at module_init, so if the bus fails to register, the > module will fail to load and all will be well in the world. > > However, if the ULPI code is built-in rather than a module, the bus > initialization may fail, but we'd still try to register drivers later onto > a non-existent bus, which will panic the kernel. > > Fix that by checking that the bus was indeed initialized before trying to > register drivers on top of it. > > Signed-off-by: Sasha Levin > Signed-off-by: Heikki Krogerus > Signed-off-by: Lu Baolu > Reported-by: Zhuo Qiuxu > Reviewed-by: David Cohen > --- > drivers/usb/common/ulpi.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c > index 0e6f968..af52b46 100644 > --- a/drivers/usb/common/ulpi.c > +++ b/drivers/usb/common/ulpi.c > @@ -132,6 +132,10 @@ int ulpi_register_driver(struct ulpi_driver *drv) > if (!drv->probe) > return -EINVAL; > > + /* Was the bus registered successfully? */ > + if (unlikely(WARN_ON(!ulpi_bus.p))) never use unlikely/likely unless you can actually measure the difference if the marking is not used. Hint, on driver probe time, you can't. thanks, greg k-h