From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9D84C2D0C6 for ; Sat, 28 Dec 2019 13:50:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 596B6206A4 for ; Sat, 28 Dec 2019 13:50:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XZl6CduL"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="rethQCw+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 596B6206A4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VSgEV0pf8TxVGPN0zHqOoukrX8erbZHqWYvlZj8YGgg=; b=XZl6CduLQpAoQV B6fEIYDRw0A3CjBnojC2HCjDPUrcH/S/Gd91iDvdUIZ16X5AHOtAY5OCl0vScR7Ll6cU6a+DDa4/m d0L66qeEs2VUeHM+Q3FepbphZ83GKIQ9ML0EBfQjLqcIV4sTeKqAqLi5XNL0/nukrx+RqH2SqmjeI a44Fm9tq8cT6bsxGUU652UvOemtx+PpJdZEuy7vsl0H0FtR3JCMzvcUFjlzSiinHwkuXof10bD0Oh DW8ybHcK5oRpCSFMzemrW00H6NZDwvY9jH4/BC2pWItvYWprgqcyI/1xDyz9EZEJD4SjGPmxHDT0n EX7B1W/9tHtNpsjNLKww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilCUT-0007it-Io; Sat, 28 Dec 2019 13:50:49 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ilCUO-0006Pu-QZ for linux-arm-kernel@lists.infradead.org; Sat, 28 Dec 2019 13:50:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RCJmzul6XUbomXCbjxTYwriW9jA1/+w+3KTp2D3QCyw=; b=rethQCw+VAf1V48foed947eZr PlhqMB2wsoYmmGRB1tR2rLPNm+c8A+yp8OD3Iw0FTZam8Uwpc2N4eblDPNYxqQU2C/+OFSv8TcKsK JerjC3ctp4j/JibUeCBVYdSwBIXrDHW6Ildjm+hpc2dDLnFiw5ihiMjMEzUN0sDWr6am0k8C+7Hjn aLN+vTK0S6MASwbFGY/mg5gwGPAKOgODs6MYT7UD4S87ngS+hGC3Qd3BdKNZZSrI2kYYay3NId7iX 8ESyKEqxBgaIMMCC20WThsuq/z8booLcmJyN1ihT0Tatd5ithZzY42NslIGRLd6yglwzHA7C3XSxO C+P+/EQoQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:59090) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ilCSD-000868-MD; Sat, 28 Dec 2019 13:48:32 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1ilCS8-0005mL-6m; Sat, 28 Dec 2019 13:48:24 +0000 Date: Sat, 28 Dec 2019 13:48:24 +0000 From: Russell King - ARM Linux admin To: Gen Zhang Subject: Re: [PATCH] board-dm644x-evm: fix 2 missing-check bugs in evm_led_setup() Message-ID: <20191228134824.GX25745@shell.armlinux.org.uk> References: <20191227023921.GA21233@zhanggen-UX430UQ> <20191227160142.GW25745@shell.armlinux.org.uk> <20191228131930.GA7214@zhanggen-UX430UQ.lan> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191228131930.GA7214@zhanggen-UX430UQ.lan> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191228_055044_863125_58E5790A X-CRM114-Status: GOOD ( 16.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bgolaszewski@baylibre.com, nsekhar@ti.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Dec 28, 2019 at 09:19:30PM +0800, Gen Zhang wrote: > On Fri, Dec 27, 2019 at 04:01:42PM +0000, Russell King - ARM Linux admin wrote: > > On Fri, Dec 27, 2019 at 10:39:21AM +0800, Gen Zhang wrote: > > > In evm_led_setup(), the allocation result of platform_device_alloc() and > > > platform_device_add_data() should be checked. > > > > > > Signed-off-by: Gen Zhang > > > --- > > > diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c > > > index 9d87d4e..9cd2785 100644 > > > --- a/arch/arm/mach-davinci/board-dm644x-evm.c > > > +++ b/arch/arm/mach-davinci/board-dm644x-evm.c > > > @@ -352,15 +352,20 @@ evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) > > > * device unregistration ... > > > */ > > > evm_led_dev = platform_device_alloc("leds-gpio", 0); > > > - platform_device_add_data(evm_led_dev, > > > + if (!evm_led_dev) > > > + return -ENOMEM; > > > + status = platform_device_add_data(evm_led_dev, > > > &evm_led_data, sizeof evm_led_data); > > > + if (status) > > > + goto err; > > > > > > evm_led_dev->dev.parent = &client->dev; > > > status = platform_device_add(evm_led_dev); > > > - if (status < 0) { > > > - platform_device_put(evm_led_dev); > > > - evm_led_dev = NULL; > > > - } > > > + if (status) > > > + goto err; > > > +err: > > > + platform_device_put(evm_led_dev); > > > + evm_led_dev = NULL; > > > > Please look again at the above change very closely. You will want to > > send an updated patch. > > > > -- > > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > > FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up > > According to speedtest.net: 11.9Mbps down 500kbps up > > Thanks for your reply. You mean the if (state < 0 ) to if (state) or > anything else? Please point out directly. This is the old everything-successful path through the code: platform_device_alloc() platform_device_add_data() platform_device_add() evm_led_dev is set to the device This is the new everything-successful path through the code: platform_device_alloc() platform_device_add_data() platform_device_add() platform_device_put() evm_led_dev = NULL And, specifically, the code sequence (I quote from your patch): if (status) goto err; err: is very stupid; it might as well not exist at all. Since other code references evm_led_dev, one can assume that we do not want it to be NULL for the success path. So, taking all this together, your patch is very very wrong, and I also find it very worrying too. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel