Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4842486imj; Wed, 13 Feb 2019 01:58:18 -0800 (PST) X-Google-Smtp-Source: AHgI3IZwvAMOTxFzgg2bVgNEsvLiQpBHQEKH0zENyoss7cpEBRLf51qGX20Rz2Kw94j62I+dFLEw X-Received: by 2002:a17:902:3f81:: with SMTP id a1mr8926222pld.258.1550051898703; Wed, 13 Feb 2019 01:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550051898; cv=none; d=google.com; s=arc-20160816; b=sVuTh+VWHsYo4sdp0DdzJsjC0Df2BzXZRnzPtEbto4+TbZK+owQJ0kZiXRXpPh4MCY nsnhNX5RCTAaZGATJw62865scwP8ZHCyoN7qG5/ZIESxtvK+56BsAWDUf0ZiQ3J7EaBN snT5PSS/dLoPP/FOyEu10Q6RzdDdzY/pKL8FsXAaYf0f32xP3jvLgmFDI/al6YeD9VGA 4VfQiI9ogal351hSxgz8gqVk9e0jXSiLCAbTRpYJVw31KRxWBTS/xIDsdFq46bjb+zXq i+ISg6Ju4uMx6ZoceQfY2RwZad5hpixFQ/bnf0KzBtJ6hRunYGFKHGvHir6f5JuRQVpW xKmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=c9eEIFfZu4XjYhuqS9pKkjrqqld4PzzNR7SgUyK0tdE=; b=tF75FOVjVt9K2bPPESYWeVod5dRxeFvZC8NXBNYqTtD93ZoPV4yB4E7DmmHLPO4Ast xnQBF6dqxQYedMuSxyd2D8bTPEOgrHzUysM0/dDtlWBX2/Cv6PM4ETjFAttzBdlLhu3R uxM5fPK8vN+fGmoxIg1r9/yXOtsWY9UCHJig/RQL+Sn7BHetxWB+cwPPYGvK5xT0fSZ1 6xjsOsR3MyZNeVRkCCJgn4lCWm4zxtSNcgjVb8CZB2WyuGSu3cNza9NUmaFck7qth9vk gCN/vUsCVA1GvrBHGCmr7vhP2wIHUPk9h8B1l8rwT+tiQ1hSwozYbd6NrrAudLRv1t6N wUQA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si15345118pgs.8.2019.02.13.01.58.02; Wed, 13 Feb 2019 01:58:18 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389023AbfBMHMd (ORCPT + 99 others); Wed, 13 Feb 2019 02:12:33 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:48590 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387769AbfBMHMc (ORCPT ); Wed, 13 Feb 2019 02:12:32 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 7634D823DCFDFA0C7F74; Wed, 13 Feb 2019 15:12:25 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x1D7CJgq085879; Wed, 13 Feb 2019 15:12:19 +0800 (GMT-8) (envelope-from peng.hao2@zte.com.cn) Received: from localhost.localdomain.localdomain ([10.74.120.59]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019021315124199-25854747 ; Wed, 13 Feb 2019 15:12:41 +0800 From: Peng Hao To: dinguyen@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Hao Subject: [PATCH] arm/mach-socfpga/pm: fix possible object reference leak Date: Wed, 13 Feb 2019 23:34:13 +0800 Message-Id: <1550072053-86356-1-git-send-email-peng.hao2@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-02-13 15:12:42, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-02-13 15:12:12, Serialize complete at 2019-02-13 15:12:12 X-MAIL: mse01.zte.com.cn x1D7CJgq085879 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org of_find_device_by_node() takes a reference to the struct device when it finds a match via get_device. When returning error we should call put_device. Signed-off-by: Peng Hao --- arch/arm/mach-socfpga/pm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-socfpga/pm.c b/arch/arm/mach-socfpga/pm.c index d486678..b782294 100644 --- a/arch/arm/mach-socfpga/pm.c +++ b/arch/arm/mach-socfpga/pm.c @@ -60,14 +60,14 @@ static int socfpga_setup_ocram_self_refresh(void) if (!ocram_pool) { pr_warn("%s: ocram pool unavailable!\n", __func__); ret = -ENODEV; - goto put_node; + goto put_device; } ocram_base = gen_pool_alloc(ocram_pool, socfpga_sdram_self_refresh_sz); if (!ocram_base) { pr_warn("%s: unable to alloc ocram!\n", __func__); ret = -ENOMEM; - goto put_node; + goto put_device; } ocram_pbase = gen_pool_virt_to_phys(ocram_pool, ocram_base); @@ -78,7 +78,7 @@ static int socfpga_setup_ocram_self_refresh(void) if (!suspend_ocram_base) { pr_warn("%s: __arm_ioremap_exec failed!\n", __func__); ret = -ENOMEM; - goto put_node; + goto put_device; } /* Copy the code that puts DDR in self refresh to ocram */ @@ -92,6 +92,8 @@ static int socfpga_setup_ocram_self_refresh(void) if (!socfpga_sdram_self_refresh_in_ocram) ret = -EFAULT; +put_device: + put_device(&pdev->dev); put_node: of_node_put(np); -- 1.8.3.1