Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp972874yba; Mon, 1 Apr 2019 22:50:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLIEEt06a1Z9xXCOPasNAekmBxHR7QTApRtc+o3c3Yq1lqvN1mIiFca306r3CS7a0lOkdt X-Received: by 2002:a17:902:9a01:: with SMTP id v1mr68872394plp.34.1554184243097; Mon, 01 Apr 2019 22:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554184243; cv=none; d=google.com; s=arc-20160816; b=ZnwXlN98Ql1Hv7w9mUFj4Xa28wx+Id8J0X0JnhMghijbImKdnzMs1thQLUsDosfv7K 0/rqIAbA+nQqGijTFFfJK71TrAFDr2yxQELh/u5Dq182kaaFyGuLTFALd2BpWX+h211B yTmpw7U0WdaQvZF7V21puxnxZ1DIy/Jz2/4o58ivfPHff/IiYu0kG+zvH3mQSmyOw8jt 4Vs/Shs3Qj7rVnQ8szStifHF/2OemuUYboR/K9bHjKXx5kw4Wd9XwWe7qaOEC3IbUmQk JQtxV2HzRL4VHEO8Ye2WVtotrkvIw4y6efKRsRqTKP/i4xq0KYO+SkRXt6FHK8eEQkMW oNaA== 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=a46XMSLt+mQt3BeXYIIlARYPtwswO1wVhXMivQvy30Y=; b=aYgrvMpeyfXdHKo+bNA8Xi1ER+xZVOoBw9lLfr6IZ0eBwAHi2F5gpIi+QYTxYMsPq6 g+1cK5S5cld2UZIQEDqcHN25jVYusGXKTAEeZl3fF8Lf3/Gjvc9c9MJFMAgh1PThZMFY TiDlN66LSV5vjDneMxlJPhdBVJ5XV0zgYCB7KUZpnvebp0tlzGCjNLMEPzaqTda6rmmt urciyAxvx0NJ/BSi8EJ6sd8Rj/wz/iQrENNrN4bsUGOmv1JN6O1ioD/DGh3qImQbXvjf hd5JZgut4hdir6GYR0owHpLVfVB1tqpYu3r9Ej884RR9Wn1ix1sUFTPCuOuQcZ4T28Qb GSRg== 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 e26si10249430pfi.54.2019.04.01.22.50.26; Mon, 01 Apr 2019 22:50:43 -0700 (PDT) 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 S1727015AbfDBFth (ORCPT + 99 others); Tue, 2 Apr 2019 01:49:37 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:23072 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725910AbfDBFth (ORCPT ); Tue, 2 Apr 2019 01:49:37 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 47BFCAA67B82F12DF593; Tue, 2 Apr 2019 13:49:33 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x325nRKm080371; Tue, 2 Apr 2019 13:49:27 +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 2019040213494063-7227938 ; Tue, 2 Apr 2019 13:49:40 +0800 From: Peng Hao To: ludovic.desroches@microchip.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, mojha@codeaurora.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Hao Subject: [PATCH v4] arm/mach-at91/pm : fix possible object reference leak Date: Tue, 2 Apr 2019 22:12:38 +0800 Message-Id: <1554214358-113444-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-04-02 13:49:40, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-04-02 13:49:23, Serialize complete at 2019-04-02 13:49:23 X-MAIL: mse01.zte.com.cn x325nRKm080371 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. Reviewed-by: Mukesh Ojha Signed-off-by: Peng Hao --- arch/arm/mach-at91/pm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 51e808a..38511a5 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -591,13 +591,13 @@ static int __init at91_pm_backup_init(void) np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam"); if (!np) - goto securam_fail; + goto securam_fail_no_ref_dev; pdev = of_find_device_by_node(np); of_node_put(np); if (!pdev) { pr_warn("%s: failed to find securam device!\n", __func__); - goto securam_fail; + goto securam_fail_no_ref_dev; } sram_pool = gen_pool_get(&pdev->dev, NULL); @@ -620,6 +620,8 @@ static int __init at91_pm_backup_init(void) return 0; securam_fail: + put_device(&pdev->dev); +securam_fail_no_ref_dev: iounmap(pm_data.sfrbu); pm_data.sfrbu = NULL; return ret; -- 1.8.3.1