From patchwork Thu Feb 7 12:02:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Yang X-Patchwork-Id: 10801027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19EF96C2 for ; Thu, 7 Feb 2019 12:35:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 072BE20952 for ; Thu, 7 Feb 2019 12:35:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE68E2C2E2; Thu, 7 Feb 2019 12:35:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_HOTMAIL_RCVD2,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1CD8520952 for ; Thu, 7 Feb 2019 12:35:13 +0000 (UTC) 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:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=vTohbpLDN0ZFoYyykBJldAN9KyBVf/hLsL1oBcw9p0U=; b=BL7eVgksDyT5os Zy0rkFiMCV4DXnfUe1aB0cDuVBbtYWFqKqOBjfefbq+SsFxjrHlDn+llHhdMkMSuRSzRmUe07jPnf uQchMVVfUkVi4Wqga2HewiEwkv7gJfGsiX9d2997LnzUYkHL/1uMaRu2qnHC3uO2pRhwyY0u47Fz0 QmP/Kd0MDklsW3e9jo1qMwBU6X58JBrtVqNCNRu6O2QNdN7VFajnljk78VFqxeTB/HPHlZ8djstOu 8i9J1o4NQnRYEggLWFl5gCkciDeHWmVsRAhPEm2Kcor+5NRqg+jOuKwtWiph5cU76gAKRehMoCnhc yIImjTa4OKrOOdp3O64w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gritb-0008JF-Hj; Thu, 07 Feb 2019 12:35:11 +0000 Received: from mail-sg2apc01olkn082d.outbound.protection.outlook.com ([2a01:111:f400:febd::82d] helo=APC01-SG2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gritM-0007jx-8V; Thu, 07 Feb 2019 12:34:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Lzpf32m/9f3fW4nlg0xIKLYFx29efJKPCIX0S/0UxJQ=; b=n0zIam/enRJfwr/CPq4i9vrlZHTCfH/rYYEKu7V+o9D8Igow55sNipdlEKaQP3xabPQY/1cA3ghlvYRbhr2CTLb/T4xzNGmpEcebXJzcIUYPsL3oZfqaFntHP2KQAHjPGhNiGlG/wBlWi+rzkwL5F/MigGkEq6dxPu87/QBinFbKGQFfVX9f+bCeqyz73/J3emixjtlhyUQ8Qon/I58yXIRNilZRfjGlPrcJOwzQ9s+GsyJXM8wJe+sELCrUFPch1zN8ISSu+sKaJegUKZ4+BpSpXKyk221vg/bq+zDOF45piEaazXuLqd92FzTEm4gzTn9GvT0/fT8HFnaE2Seq7Q== Received: from HK2APC01FT044.eop-APC01.prod.protection.outlook.com (10.152.248.54) by HK2APC01HT177.eop-APC01.prod.protection.outlook.com (10.152.249.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1580.10; Thu, 7 Feb 2019 12:02:45 +0000 Received: from HK0PR02MB3634.apcprd02.prod.outlook.com (10.152.248.60) by HK2APC01FT044.mail.protection.outlook.com (10.152.249.115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1580.10 via Frontend Transport; Thu, 7 Feb 2019 12:02:45 +0000 Received: from HK0PR02MB3634.apcprd02.prod.outlook.com ([fe80::d582:b3ef:f46a:4735]) by HK0PR02MB3634.apcprd02.prod.outlook.com ([fe80::d582:b3ef:f46a:4735%3]) with mapi id 15.20.1580.019; Thu, 7 Feb 2019 12:02:45 +0000 From: Wen Yang To: "bbrezillon@kernel.org" , "miquel.raynal@bootlin.com" , "tudor.ambarus@microchip.com" , "richard@nod.at" , "dwmw2@infradead.org" , "computersforpeace@gmail.com" , "marek.vasut@gmail.com" Subject: [PATCH v4 2/3] mtd: rawnand: jz4780: fix possible object reference leak Thread-Topic: [PATCH v4 2/3] mtd: rawnand: jz4780: fix possible object reference leak Thread-Index: AQHUvt0J96rvaNo3TE6LMpRtXiJFjw== Date: Thu, 7 Feb 2019 12:02:45 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR07CA0085.namprd07.prod.outlook.com (2603:10b6:a03:12b::26) To HK0PR02MB3634.apcprd02.prod.outlook.com (2603:1096:203:97::14) x-incomingtopheadermarker: OriginalChecksum:88098E8751C5AF91A6261678D7F47845D25B84ADC64DD71B9B2A9C9C57C855FD; UpperCasedChecksum:46A6DDE9AB84E472DED7FB1A1911B1CBF63AA01C133D0FA052DF0F8E646449BA; SizeAsReceived:9219; Count:63 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-tmn: [YPF7PtKzroP2FQgOipseTjQjs1FGIh5W] x-microsoft-original-message-id: <1549540786-12196-1-git-send-email-yellowriver2010@hotmail.com> x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HK2APC01HT177; 6:1aJIcJuTBQF6tB7/Ei9jJOcudzu7KpDevIFfszth4gjN6tGUjTsMq4bQLsDCp1sreDcdsFN44P2SIyvKJUAGg3UszHINUgj/v0YNv3rxRkgZGKdpKjDZL5N3epUTNKHRkecHST+LU70+Eib1ygkU02rkjl51rq0JagqGQNqjljmJVFDjW0K4D20uVrGqJe4qv0U39bX9XBWZ5ezMM076iQ3/mC+UsIFpnxJPIsEkJo3SAeFVz6FvKQPw9IH9xe2Mgvm6FepMFJpta/2f+2Fvt2UX6QD3Ot0Ozmo8BhmJ/1eyGtaQnMWqrCfmPEfh7nFztIOvRyALv25OafkOMXANuXGPxh01oZoW76aoBVoUWC9kodr+2KvBDB7Bf4rO6ISH7QWEX0t4DUt14FupWCo1/SbQQky4ZRwWFgKj9iNzU69l7L04gzp2kNfzt+AtlnPeT6cIynO5tfWDlT3YeI0Psg==; 5:TRRIv+ZHBvKHh3W/K/tm1uf7vaUqM8IEufMn2ubnwp5v9kbRd/xwU3qrmTEq2Pe41xl06MVaMYh55gbtHozZQMbJAz2973zufoABK4SZSeLJcOfcfs/6kdf+Y+Lskt8P+Uoh0tdHU+d5+GOE5G2YLN94KEBopjbS9lnV30Q8CA40ta/u/HXmlwju7UpzaxKroajTukq3DTqI+fjVNXuSiw==; 7:ynYl5Id4TpGh3aPzjTqCYKCzaFWih7eVv60AP92akWj5vSNtpkjBfiTZhSIe6TXluKML0m9bFjYZIGmNQWGGMuA3K70od2NbEguB1vnSjuleE1UCs+sT2MLVesOdGtcUbOi047J7WucSKotuZVD0rw== x-incomingheadercount: 63 x-eopattributedmessage: 0 x-ms-exchange-slblob-mailprops: mmMLu+WorSyPNTlVaAqNPlkb+GWRLMOe9FAuwZEUmefngDuc9mDArFWFHoUwDep25QPQtWyHdALgI6JGRpvr9RpSgDZFi1a8yUH5eH8TaPKY246i578plXPMjFbdli6PbimVLd/SqeJ1nkR7+9GO62qXzW7RInTKVC2H5vIsneMWkjkYLh8jZWgcNL3eGhiOsTuKQGp4Mv13tUk4QHOZ41lC5J8ZUYRD8TFPyNX2qWognNm+bZxmzJqWfDojN4fc73S1CwZyH0OEe0hNo7l4hSBTBZ2n2p20I6hTbxLZrOZteVDUDm7veXVJlkcGkfkh/GGc1KSMAIgNfRmqrpLDOLBqGpCgvyXcgRNZTwFWnWrhsC903xD7E2R64asir3X9H/lHj58ej+q+XJ2hAFyt0OpA4pETiGdt0LFLSDRThq4UPnogy4wQ+npQIjMbDt3M61DUTb6dOmJ0eklJS+S43ZblnApt/wM2DUD0TIKtfJiHgCqN1qahsb8Fr4n6E25fPCzSR14Cm+aCEPZH7MsUuWXolGLx8MI0Knx0bBoex4KD4yxQo4rBBoIbm1CABPcqXXwZhaP7m3GYdonjxzzXPymMHQfF/OL3CW/nCXHdmOYYGY+qJs5cx8fGg5uVY8BjnaS0lzxEdegKmBvOe7wA20urChx+7EnwHQL6Y2BhNY6BfzCvRWLH2ymQd1wy2AWmR2xVDXgpT/c+uRhViaT7AwlNfF0VXsDH x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(201702181274)(2017031323274)(2017031324274)(2017031322404)(1601125500)(1603101475)(1701031045); SRVR:HK2APC01HT177; x-ms-traffictypediagnostic: HK2APC01HT177: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(4566010)(82015058); SRVR:HK2APC01HT177; BCL:0; PCL:0; RULEID:; SRVR:HK2APC01HT177; x-microsoft-antispam-message-info: jTjqLQs8Q0Qm38VpvFtNyRdk4i2R9OMBucmzo2vYPfFGggiphsZWkFBAlz+gqZYU MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 9a4e3081-9524-43cf-bfc3-dcaef82d5da1 X-MS-Exchange-CrossTenant-Network-Message-Id: 892bc856-f2c4-49b6-5ab4-08d68cf42ba9 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 9a4e3081-9524-43cf-bfc3-dcaef82d5da1 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Feb 2019 12:02:39.2630 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2APC01HT177 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190207_043456_369125_9C65FFEA X-CRM114-Status: GOOD ( 12.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alexandre.belloni@bootlin.com" , Wen Yang , "linux-kernel@vger.kernel.org" , "ludovic.desroches@microchip.com" , "linux-mtd@lists.infradead.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-Virus-Scanned: ClamAV using ClamSMTP 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 --- v4->v3: Add people in Cc and remove all lines. v3->v2: Avoid two times of calling grtform_get_drvdata() v2->v1: Since there is the only one user, let's remove the err_put_device label. drivers/mtd/nand/raw/jz4780_bch.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/jz4780_bch.c b/drivers/mtd/nand/raw/jz4780_bch.c index 7201827..7aab851 100644 --- a/drivers/mtd/nand/raw/jz4780_bch.c +++ b/drivers/mtd/nand/raw/jz4780_bch.c @@ -281,12 +281,14 @@ 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); - bch = platform_get_drvdata(pdev); + if (!bch) { + put_device(&pdev->dev); + return ERR_PTR(-EPROBE_DEFER); + } + clk_prepare_enable(bch->clk); return bch; From patchwork Thu Feb 7 12:02:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Yang X-Patchwork-Id: 10800995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B29F213B4 for ; Thu, 7 Feb 2019 12:03:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A034E2A5F1 for ; Thu, 7 Feb 2019 12:03:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9344E2C448; Thu, 7 Feb 2019 12:03:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_HOTMAIL_RCVD2,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 407E42A5F1 for ; Thu, 7 Feb 2019 12:03:15 +0000 (UTC) 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:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qQv+jNBFLwq/Ba1WN8eO+A8SnrDmTt1Eh4Q1BNWVAjM=; b=tFMsf7yO1l/TIU mp4Q+mnzLTP9pP+S5CMVL9xMBmNbDHjhfya6CAc3PH7e+pJeI4LmQNI4RA5Qv1pJhTXTUe80c9HaG A/Ta9MM2MjGW4krGQkL1rbRYwtiVH17aQa/nsO6p+fokmJTg1f9neoG5rZUBXuaT1dGUZwN+F6i1K 4KIYVjQf6DBxu709Yny6CnUqBE0swBlJdnN4aRwkD2n+MOww8Q048TnwuMyaDAPqfegB5wQ2c2D/D gdENlmCv5N+uotZSa7iiQYyJ/IufCn2yr5PTOtCCKfIXb1Lj1N1n8/+3vtIT9mIgxWQbOo8LqcaFD lPz+he1B0uI6Ujd45sqA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1griOd-0004Jz-RE; Thu, 07 Feb 2019 12:03:11 +0000 Received: from mail-oln040092255014.outbound.protection.outlook.com ([40.92.255.14] helo=APC01-HK2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1griOQ-00048s-TD; Thu, 07 Feb 2019 12:03:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MlRtGmlMeO04rl6IXpPYU/ERNKgJzhXggPlxIi0mAqI=; b=h6eQrfgJ8Q9rQwcyUXAEi7F4nsFYAvB+On9qrFH7DoF42qvqfYzoG/tmoRDr+1rrrH8yhiAZo2dtLBu/t30r7wg8bWIptuLdz1kqbyCTGWu8MBVkKRzQ2iwajUJMfuHD9ku7zsgSR0kfsKVk/i5UIBaoMkpyMUZ1aVDTV76N1vXOzLpdMokfAneZDWtdhEbyd1cS0D4dcpMT3zKqhI7DWlMXXCl+0DY+p7JdZwpOe697lIRx90aRa6pCe47cT7z+TMbl1Io29j5pAjMtVxGxeTVxSzZ+AraFSs2GJ+w2f+sWPBfkqhYIVBlxWLwj17aO+uJJIv7PF8WZBx6KJrQH/A== Received: from HK2APC01FT044.eop-APC01.prod.protection.outlook.com (10.152.248.59) by HK2APC01HT077.eop-APC01.prod.protection.outlook.com (10.152.249.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1580.10; Thu, 7 Feb 2019 12:02:52 +0000 Received: from HK0PR02MB3634.apcprd02.prod.outlook.com (10.152.248.60) by HK2APC01FT044.mail.protection.outlook.com (10.152.249.115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1580.10 via Frontend Transport; Thu, 7 Feb 2019 12:02:52 +0000 Received: from HK0PR02MB3634.apcprd02.prod.outlook.com ([fe80::d582:b3ef:f46a:4735]) by HK0PR02MB3634.apcprd02.prod.outlook.com ([fe80::d582:b3ef:f46a:4735%3]) with mapi id 15.20.1580.019; Thu, 7 Feb 2019 12:02:52 +0000 From: Wen Yang To: "bbrezillon@kernel.org" , "miquel.raynal@bootlin.com" , "tudor.ambarus@microchip.com" , "richard@nod.at" , "dwmw2@infradead.org" , "computersforpeace@gmail.com" , "marek.vasut@gmail.com" Subject: [PATCH v4 3/3] mtd: rawnand: mtk: fix possible object reference leak Thread-Topic: [PATCH v4 3/3] mtd: rawnand: mtk: fix possible object reference leak Thread-Index: AQHUvt0NR4D3q6yT0EC6btoPU9owCg== Date: Thu, 7 Feb 2019 12:02:52 +0000 Message-ID: References: <1549540786-12196-1-git-send-email-yellowriver2010@hotmail.com> In-Reply-To: <1549540786-12196-1-git-send-email-yellowriver2010@hotmail.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR07CA0085.namprd07.prod.outlook.com (2603:10b6:a03:12b::26) To HK0PR02MB3634.apcprd02.prod.outlook.com (2603:1096:203:97::14) x-incomingtopheadermarker: OriginalChecksum:20711C5A04AF1C2CDD6830050E986AE7BB047610DF1F663679BEBA23F49C2501; UpperCasedChecksum:2D7C35A5EC47F9DC57C6991804147F98C80426EC35435D611F1E925A6D9ABC15; SizeAsReceived:9358; Count:65 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-tmn: [GKplGarwoKbuY3zLUKrXli/yxibu54nO] x-microsoft-original-message-id: <1549540786-12196-2-git-send-email-yellowriver2010@hotmail.com> x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HK2APC01HT077; 6:Inzb1gy3mHElrbnG50gOfKR/NGiAwT9L8GQF5iAVjxT4gCOzETqczPQ85JfN9fSuivgtbZvpWs7DldNP1GeWway6o+MqZRjmlUlE9fMoW8YG5GdNkMAcSGYgrQZB7kCuNdzJ2eDnV38Ef4btWRmOlRnNh28AdeuLZ2i1RYI0CauI7RRSV5AiuG5oB5BW47eXCF1JX3RAwU/114tipyAG81eHZr8mFrrMFaNDm0P660otEY1m2BmDKwzQi3eMPxqrtyEUUzsLZhftn63sSbVFauU1xmdIsKlps5w4lHCaD8W2NrtODtiCUY0fqNSxIN6Ltj03eSE9Xv7n/nESVwszfZcFUXSE1HGAKumuz7oaLU7xRRAesYRfRUYPJDHpVTRhb7CwFmJpOorIs0rBteRXVFK7+TUJpbRaQGZo6XHTKjeXuRXY8AyOdhbL3lEDI1A8FvCtaJCCqoBgmc1KuxXTkw==; 5:bQTAk77tLisoQnPoc6+niuoayBE66TTmqIogNGGwtINbqQDJleIedjTZSiCT6aTFZgm5ZswX7jSSKp1UXqG35UyRdc0k7OHQjjfbXdg+hTh3/HalwrlFz6sOXEhkTwcyGbgU01urC6MCNLHqIxiRS/H9lPeYuNGVmkEopddTt2srnCKzA5+xzvs6vATOazD9GG+eWtQ69Qae7yUmaI3TRw==; 7:3+mdOF+8xx/1LPDxLyGt3AIT9TH89PsJzTtxnPNZpb+k11Mu58+f5okMIRP+Wk1jGttQQICuHca2H76NEgzNqFL3z3ppdfqZy3QOimzJvwJrc26DDdvxiIKCIrAhWUVOlHaNyoXppIhbrvUhQzsBGw== x-incomingheadercount: 65 x-eopattributedmessage: 0 x-ms-exchange-slblob-mailprops: b0omxY8GwpZtOL5FmEVprVixbmp3zFeA/X3DMB9dduFRetOGFgucCI1PdmiY5ct8utm714/6636jCIVJ/hi2DtGpCf5wxputlpTTbPy3Uh/DQ4/IcTkMvjdAgfUq6e2jkggUFQCdRQHMumtiNsnLmRxrtE7+y7yMK1cahJlsr5owGp/PtfffyOgL1gtl9eJiYvb+SOhF07QLeMptxR7P4N1JXdGmvrtDX3+r5SaSK6n25FWq4pKbHvGeUVqjEee5s8m72xdb93RC+XWrOyIaQYlQiPGb8k9tRyNRPHhKaEdesH0coDjT9oo9RUhKBlTIl4xgyDjUJ4hXA0hK1llKaF0rOncUxTMf1wz4k1Vv9Zz4Rcug1E/TNmnRemXG+gL8qE1JPsudYT9U0HmIBDhbyon7vuZj5x3m1tz7Zy4+OSUZ2dBq6XypCHzacRcZAvj1NROoStLnZudqznMBxDVhRKHmfQHDo+u8GxBfBrQV5Bhh68GJtF+KkI1DOBmFZzX0qbu2cK3cnn8HDfHXnJtQ/I4986qvEGJONTNBLsuDoi217fq2BjByalt5qSAVaAs4ujnqNgjM9BQ4ZwiAXYrFIqXBkdYvyhVwK3l1MKjdQyK2f6rWbsWOuGB1y99ev4ohmmo/N6li4rnK6wGtgZ4ApVDRNtzXYzT2+lGJQPE+ZRbAYlmD9LuTaZ2py6FdLhBarsHGZFmlR/WdfRbDma4SDXDh01qVs49M7hUhwJqsO1KkY/q4h3hTOZG8a5fiLnYN x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(201702181274)(2017031323274)(2017031324274)(2017031322404)(1601125500)(1603101475)(1701031045); SRVR:HK2APC01HT077; x-ms-traffictypediagnostic: HK2APC01HT077: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(4566010)(82015058); SRVR:HK2APC01HT077; BCL:0; PCL:0; RULEID:; SRVR:HK2APC01HT077; x-microsoft-antispam-message-info: VY2OKy5QAM2q1rH/z9vr3/6Ysaik40iR6D2AOCliDWVfzLGXNVQlPJWycO/6wbdf MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 9a4e3081-9524-43cf-bfc3-dcaef82d5da1 X-MS-Exchange-CrossTenant-Network-Message-Id: dd358e44-15dd-4a83-c348-08d68cf42fa2 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 9a4e3081-9524-43cf-bfc3-dcaef82d5da1 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Feb 2019 12:02:46.0037 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2APC01HT077 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190207_040258_946368_9FB90C18 X-CRM114-Status: GOOD ( 12.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alexandre.belloni@bootlin.com" , Wen Yang , "linux-kernel@vger.kernel.org" , "ludovic.desroches@microchip.com" , "linux-mtd@lists.infradead.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-Virus-Scanned: ClamAV using ClamSMTP 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: 1d6b1e464950 ("mtd: mediatek: driver for MTK Smart Device") Signed-off-by: Wen Yang --- v4->v3: Add people in Cc and remove all lines. v3->v2: Avoid two times of calling grtform_get_drvdata() v2->v1: Since there is the only one user, let's remove the err_put_device label. drivers/mtd/nand/raw/mtk_ecc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/mtk_ecc.c b/drivers/mtd/nand/raw/mtk_ecc.c index 6432bd7..db804fe 100644 --- a/drivers/mtd/nand/raw/mtk_ecc.c +++ b/drivers/mtd/nand/raw/mtk_ecc.c @@ -267,11 +267,14 @@ static struct mtk_ecc *mtk_ecc_get(struct device_node *np) struct mtk_ecc *ecc; pdev = of_find_device_by_node(np); - if (!pdev || !platform_get_drvdata(pdev)) + if (!pdev) return ERR_PTR(-EPROBE_DEFER); - - get_device(&pdev->dev); ecc = platform_get_drvdata(pdev); + if (!ecc) { + put_device(&pdev->dev); + return ERR_PTR(-EPROBE_DEFER); + } + clk_prepare_enable(ecc->clk); mtk_ecc_hw_init(ecc);