Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1008668yba; Sun, 31 Mar 2019 19:58:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8txgD/6zB4af0ag7FHhb4K5RJSJtobw4UPLKfPrkXPjZ2cLiGxLL6HaDfpLIQKCIXwgjO X-Received: by 2002:aa7:91d5:: with SMTP id z21mr28832313pfa.222.1554087499110; Sun, 31 Mar 2019 19:58:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554087499; cv=none; d=google.com; s=arc-20160816; b=elfN2LUHZndLvLya3GWuay1vnCn4jlychHHDzyLvr2yLX4X2ZKDxYA++hnxZm8E7zT 8PpTnhy56oSY2NSoRrUzxYm+Jlf8K8ztVpyxS8XT+6TnI/eqADUK2RTvAuc8hirmXSET GsWIbQpgRO4p85rBezyplotFMv5M4ydQraaOe2Ieb02E6p7+TM8NxOdUPYD9hx67whOI RyzQC/6Y2pEbT0i53czRef1FSQpjgsBurIhWmtqIM+YLJzU+RRbDInrH72Mxkrw+cSm8 JjHjArgG+Zj8lax5tO1iSF3mWsCYJo4NUuLJqjmcnnXRsRLxi+YiFV6mZuk9nW1FcV7C AsPg== 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=oWYZnxKwLNcDAvtOkuYg/EdVNCmqKbiWQNbpmjp08iw=; b=ZsHN8UYC9t09C7sYgFCJNtrIXyRYiYAcTCjiPS9xSGoVRekU8aIbcQ4FWl/wCV15ur +Sp1WasIPUJBdvt7F+DGa9tqOQ+tNOVQ5ehSRiMCW02VFBbCkYEb6q5d9Cxj2p/R0Vj7 3miFzfaorOpafU/WrC/9cXJGvyxzIBnBFdZ4Hq1bipJc8TY9kuy4ol4paEPLHivWItyf QvIyVUkb7j23aY1vswkwOpoAeIXUc8SoZApTeYpQPADJ1VzJH450BS4BO1PgdlsOWG1v hWZAc2g1r14D/WZShrkYhFF/VULmlSbesxMQtDi7Q5FsAU5UeoXMMvRSo+Jr27ZukOb1 ie7g== 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 a5si1908358pgc.51.2019.03.31.19.58.03; Sun, 31 Mar 2019 19:58:19 -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 S1731684AbfDAC5a (ORCPT + 99 others); Sun, 31 Mar 2019 22:57:30 -0400 Received: from out1.zte.com.cn ([202.103.147.172]:42856 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731593AbfDAC5a (ORCPT ); Sun, 31 Mar 2019 22:57:30 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id E16A590D6EC2F8FDFEC9; Mon, 1 Apr 2019 10:57:26 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x312vFiN081988; Mon, 1 Apr 2019 10:57:15 +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 2019040110571908-7052397 ; Mon, 1 Apr 2019 10:57:19 +0800 From: Peng Hao To: ludovic.desroches@microchip.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Hao Subject: [PATCH V2] arm/mach-at91/pm : fix possible object reference leak Date: Mon, 1 Apr 2019 19:20:31 +0800 Message-Id: <1554117631-108215-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-01 10:57:19, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-04-01 10:57:15, Serialize complete at 2019-04-01 10:57:15 X-MAIL: mse01.zte.com.cn x312vFiN081988 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-at91/pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 51e808a..b60fcc9 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -591,7 +591,7 @@ 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_1; pdev = of_find_device_by_node(np); of_node_put(np); @@ -620,6 +620,8 @@ static int __init at91_pm_backup_init(void) return 0; securam_fail: + put_device(&pdev->dev); +securam_fail_1: iounmap(pm_data.sfrbu); pm_data.sfrbu = NULL; return ret; -- 1.8.3.1