From patchwork Wed Feb 17 22:44:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Cartwright X-Patchwork-Id: 8343681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 92BB8C0553 for ; Wed, 17 Feb 2016 22:47:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 06D292024C for ; Wed, 17 Feb 2016 22:47:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13680203E9 for ; Wed, 17 Feb 2016 22:47:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWAq9-0006u3-4G; Wed, 17 Feb 2016 22:44:57 +0000 Received: from skprod2.natinst.com ([130.164.80.23] helo=ni.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWAq5-0006rR-Lm for linux-arm-kernel@lists.infradead.org; Wed, 17 Feb 2016 22:44:54 +0000 Received: from us-aus-mgwout1.amer.corp.natinst.com (nb-chan1-1338.natinst.com [130.164.19.134]) by us-aus-skprod2.natinst.com (8.15.0.59/8.15.0.59) with ESMTP id u1HMiG9Q030299; Wed, 17 Feb 2016 16:44:16 -0600 Received: from jcartwri.amer.corp.natinst.com ([130.164.14.198]) by us-aus-mgwout1.amer.corp.natinst.com (Lotus Domino Release 8.5.3FP6 HF1218) with ESMTP id 2016021716441652-1097087 ; Wed, 17 Feb 2016 16:44:16 -0600 Received: by jcartwri.amer.corp.natinst.com (Postfix, from userid 1000) id 056DC300762; Wed, 17 Feb 2016 16:44:16 -0600 (CST) Date: Wed, 17 Feb 2016 16:44:15 -0600 From: Josh Cartwright To: Tony Lindgren Subject: Re: Bunch of machines are not booting in next again, GPIO regression? Message-ID: <20160217224415.GA3866@jcartwri.amer.corp.natinst.com> References: <20160217192755.GC21202@atomide.com> <20160217195543.GA871@jcartwri.amer.corp.natinst.com> <20160217201259.GA16028@deathstar> <20160217202224.GD21202@atomide.com> MIME-Version: 1.0 In-Reply-To: <20160217202224.GD21202@atomide.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 02/17/2016 04:44:16 PM, Serialize by Router on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 02/17/2016 04:44:16 PM, Serialize complete at 02/17/2016 04:44:16 PM Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-02-17_11:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160217_144453_951544_7DBA60FB X-CRM114-Status: GOOD ( 20.51 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linus Walleij , Johan Hovold , linux-gpio@vger.kernel.org, Mark Brown , Michael Welling , Markus Pargmann , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Feb 17, 2016 at 12:22:25PM -0800, Tony Lindgren wrote: > * Michael Welling [160217 12:13]: > > On Wed, Feb 17, 2016 at 01:55:43PM -0600, Josh Cartwright wrote: > > > On Wed, Feb 17, 2016 at 11:27:55AM -0800, Tony Lindgren wrote: > > > > Hi Linus, > > > > > > > > Looks like ff2b13592299 ("gpio: make the gpiochip a real device") > > > > broke booting on all omaps, and probably other machines too according > > > > to this: > > > > > > > > https://kernelci.org/boot/all/job/next/kernel/next-20160217/ > > > > > > > > So far we've gone from 1 failed machine with next-20160216 to > > > > 18 failed machines with next-20160217. > > > > > > > > The error I'm getting on omaps is below with debug_ll enable, > > > > any ideas? > > > > > > Hey Tony- > > > > > > Looks like the newly allocated gpio_device object isn't zeroed, > > > confusing dev_set_name. Can you give this a try? > > > > > > Josh > > > > > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > > > index d8511cd..59f0045 100644 > > > --- a/drivers/gpio/gpiolib.c > > > +++ b/drivers/gpio/gpiolib.c > > > @@ -435,7 +435,7 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) > > > * First: allocate and populate the internal stat container, and > > > * set up the struct device. > > > */ > > > - gdev = kmalloc(sizeof(*gdev), GFP_KERNEL); > > > + gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); > > > if (!gdev) > > > return -ENOMEM; > > > gdev->dev.bus = &gpio_bus_type; > > > > As you can see by my post on the GPIO mailing list, a boot failure > > was occurring on the Dragonboard 410C: > > http://permalink.gmane.org/gmane.linux.kernel.gpio/14360 > > > > With the above patch the board now boots. Good catch. > > Yup fixes the issue for me too. Linus- Here's a properly cooked patch. Otherwise, feel free to squash it in if it's easier for you. Josh -- 8< -- Subject: [PATCH] gpio: use kzalloc to allocate gpio_device The use of kmalloc() to allocate the gpio_device leaves the contained struct device object in an unknown state. Calling dev_set_name() on a struct device of unknown state can trigger the free() of an invalid pointer, as seen in the following backtrace (collected by Tony Lindgren): kfree kobject_set_name_vargs dev_set_name gpiochip_add_data omap_gpio_probe platform_drv_probe ... Reported-by: Michael Welling Reported-by: Tony Lindgren Tested-by: Michael Welling Tested-by: Tony Lindgren Signed-off-by: Josh Cartwright --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index d8511cd..59f0045 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -435,7 +435,7 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) * First: allocate and populate the internal stat container, and * set up the struct device. */ - gdev = kmalloc(sizeof(*gdev), GFP_KERNEL); + gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); if (!gdev) return -ENOMEM; gdev->dev.bus = &gpio_bus_type;