Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5250594ima; Tue, 5 Feb 2019 08:39:35 -0800 (PST) X-Google-Smtp-Source: AHgI3Iape5GqmG17DQisP2LxF7AXj9oezUw3BKt/M/kmEe8BbWonLvnvidC76LV668m1s/mt6FPp X-Received: by 2002:a17:902:2a26:: with SMTP id i35mr2302288plb.321.1549384775428; Tue, 05 Feb 2019 08:39:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549384775; cv=none; d=google.com; s=arc-20160816; b=MuRDp7BAH+9CVoYKugoZnWR6HNdOJUJjHqPeOyHiH/xnGNfuRXahlUt4M6OdXUvWnP vDUd3l0GP4wOfK8XrAYAVoC7Zct7NY405G62TuVUKq6l+NVNT5vAMKjxc7bm83M+LWxW bhtbZKkOvRKwgF9XCun66qyBFTuuUPT2TrhmAUpTN5nw+oZdE0yrn0gGlzpjS6jD44wG gzD4d/KNEDCc/p4JwBg3OSK91V1mBoHOwTlvEbIk0BaM6m24gsemtTPp1jk2sfD+pDVC TIoV7MhFKjUVm+xZ8jhbPXPnyJNJlZqiqqxgu2gd4OY5eIg5LBixox7yG6DeyHMTDGx2 14AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=0zI8k199RtAf/l+KXZN0V9EdEAqxEOZtg1CfDPHWULg=; b=HitKs7A7mAD+e7vkCGQzKm9jrJCK9U4P6pRG/zdct/LNDwqZRfAYq1L3j8+z506uIO z4+r9S7Aat5FojuDwuQg4Xe9YRmFRCD2jO/mkabXz2eytEtooGeYcrYJS5L9RbkfBEeA ezQqRRKCndcWRp83bjvWpgee7DmnIYJpKOfOPBSGyQwiYgHTy4zXd8hJlZqGxl1nnbmD pkcbk7dQlHHwZBpieATQyNvFJ+UKb/MI15w71XCSLtG8RuylzVed1Q+DenXK7ZVh1EAV Xe0txlF747b9M1yMmpbMYpzwBBsvfr1UfY3Ao/uPf0zLIE8i1bMjnDbXK2Uudlsm6SGv 92xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zwirwUqr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bf4si2688365plb.163.2019.02.05.08.39.18; Tue, 05 Feb 2019 08:39:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zwirwUqr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730461AbfBEQVr (ORCPT + 99 others); Tue, 5 Feb 2019 11:21:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:34778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726887AbfBEQVq (ORCPT ); Tue, 5 Feb 2019 11:21:46 -0500 Received: from localhost (unknown [91.160.177.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE2D220844; Tue, 5 Feb 2019 16:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549383705; bh=Av3aH/8ZR4Ux6m6lYUfKR7n3sD1IG70okAvKsiDB3Ew=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=zwirwUqre7/jkP47KEeyqGsWWzcmys0/xFFT7Ks69UXJLEMAdw0CI7f3mzEYyb5YG lsDx5yvyVT9hyuacO6GJBPSVov0hfoKnwpAYXiCYr1AlkMZxKj9QLFJYk335F7nnOR oJ3w9LwmyiNsg1WjqPHj4baf4YIHwqETDFkfHt0c= Date: Tue, 5 Feb 2019 17:21:23 +0100 From: Boris Brezillon To: Miquel Raynal Cc: Wen Yang , "harveyhuntnexus@gmail.com" , "richard@nod.at" , "dwmw2@infradead.org" , "computersforpeace@gmail.com" , "marek.vasut@gmail.com" , "nicolas.ferre@microchip.com" , "alexandre.belloni@bootlin.com" , "ludovic.desroches@microchip.com" , "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] mtd: rawnand: jz4780: fix possible object reference leak Message-ID: <20190205172123.13ed9469@kernel.org> In-Reply-To: <20190205165502.2b8be890@xps13> References: <20190205165502.2b8be890@xps13> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 5 Feb 2019 16:55:02 +0100 Miquel Raynal wrote: > Hi Wen, > > Wen Yang wrote on Tue, 5 Feb 2019 > 15:07:21 +0000: > > > of_find_device_by_node() takes a reference to the struct device > > when it finds a match via get_device, there is no need to call > > get_device() twice. > > We also should make sure to drop the reference to the device > > taken by of_find_device_by_node() on driver unbind. > > > > Fixes: ae02ab00aa3c ("mtd: nand: jz4780: driver for NAND devices on > > JZ4780 SoCs") Signed-off-by: Wen Yang > > Suggested-by: Miquel Raynal > > Cc: Harvey Hunt > > Cc: Boris Brezillon > > Cc: Miquel Raynal > > Cc: Richard Weinberger > > Cc: David Woodhouse > > Cc: Brian Norris > > Cc: Marek Vasut > > Cc: linux-mtd@lists.infradead.org > > Cc: linux-kernel@vger.kernel.org > > --- > > v2->v1: Since there is the only one user, let's remove the > > err_put_device label. > > > > drivers/mtd/nand/raw/jz4780_bch.c | 8 +++++--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/mtd/nand/raw/jz4780_bch.c > > b/drivers/mtd/nand/raw/jz4780_bch.c index 7201827..363465c 100644 > > --- a/drivers/mtd/nand/raw/jz4780_bch.c > > +++ b/drivers/mtd/nand/raw/jz4780_bch.c > > @@ -281,10 +281,12 @@ static struct jz4780_bch > > *jz4780_bch_get(struct device_node *np) struct jz4780_bch *bch; > > > > pdev = of_find_device_by_node(np); > > - if (!pdev || !platform_get_drvdata(pdev)) > > + if (!pdev) > > return ERR_PTR(-EPROBE_DEFER); > > - > > - get_device(&pdev->dev); > > + if (!platform_get_drvdata(pdev)) { > > + put_device(&pdev->dev); > > + return ERR_PTR(-EPROBE_DEFER); > > + } > > > > bch = platform_get_drvdata(pdev); > > clk_prepare_enable(bch->clk); > > Acked-by: Miquel Raynal Don't plan to take that one (or any other ref leak fix) in the mtd/fixes branch, feel free to queue it to nand/next.