Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp38777yba; Mon, 1 Apr 2019 01:04:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2Klp0fG0xUrC0VxL59i5TF0AEWQq4c5YvBPM/6pmDiZsjXLmgevgNRxVEAsFsBZ8ZE0J8 X-Received: by 2002:a63:5b4b:: with SMTP id l11mr58992159pgm.82.1554105848030; Mon, 01 Apr 2019 01:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554105848; cv=none; d=google.com; s=arc-20160816; b=jINeyTQHvYL1hXoSg8WRoSeLgUXoVMj0Ht69rb4F621hwAlHx8rsJbuwmh5vnMclZF 5OlC45oNI8e4scAGitwlfnabfulicmD9fO9VPJUmcadbL3xhYjLHospPDpQwlDVwB80S XwkhtvNbyBHCpWUwMc8fGk1t5tcDlPNJDijIgsCXdsMzdhVNOhzr8hQPLGZTTY/BhY40 Vcoum9xYEqXOvoPIUEfcgnd6bp4p/uCl5F/DHTJwXIu6V4+Vgmv+74ryMfhMTcbsHBJG 3sfrZLy4zQ8bvLSCuLRz51f5niZK1Pz1BZ4+EgBTXu05cG9HfcGauoHy4o02VoUYDkXc S2IQ== 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=gM/M3/0cvkouVuhnWePCnqkors/JFGXaRc0ZVg3EJmw=; b=VqMSKmzwocx7/9fYLBDNMlg7U0rsTYc4lQIjC94mGi27jC8PJCoU4cA/3Pz4Ysyaqx tAiqP3i7uHzjImtXzT2IQ/Ia3ierfjDyjEDKqwyHfCWxYFoyu0p7SP2Eq+GBPNfsFSQF WP4TEkRB1JTnpvmvuuYwaFO+egYzN29F0LRN0FIGu7IzzR/eoo73bZSdOEn9nS6NpoJI sNm0AlLZDg3UY7De6GRCEKTDzcE+sxZzPS3F9SJ7wcH8JuqchHCQh2QsILc1FNQbkvp8 M8/Hmd4gYxOcdKpcZ32rYWdCvNhpOU3kdUgHYlf7GDIaxvEHMmi2mFGMZ0tItU5JDcAK iDBg== 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 k4si6782686pgq.208.2019.04.01.01.03.52; Mon, 01 Apr 2019 01:04:08 -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 S1732073AbfDAIDR (ORCPT + 99 others); Mon, 1 Apr 2019 04:03:17 -0400 Received: from mxhk.zte.com.cn ([63.217.80.70]:61186 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731833AbfDAIDQ (ORCPT ); Mon, 1 Apr 2019 04:03:16 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 4CF4D7573B04B2794B5D; Mon, 1 Apr 2019 16:03:14 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x31837f0055200; Mon, 1 Apr 2019 16:03:07 +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 2019040116031351-7106487 ; Mon, 1 Apr 2019 16:03:13 +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 v3] arm/mach-at91/pm : fix possible object reference leak Date: Tue, 2 Apr 2019 00:26:21 +0800 Message-Id: <1554135981-109288-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 16:03:13, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-04-01 16:03:07, Serialize complete at 2019-04-01 16:03:07 X-MAIL: mse01.zte.com.cn x31837f0055200 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 | 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_get; 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_get; } 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_get: iounmap(pm_data.sfrbu); pm_data.sfrbu = NULL; return ret; -- 1.8.3.1