Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2536232yba; Mon, 6 May 2019 07:39:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHeK+T+rljGuHUlOuOFr8hF7bnjbsGDRX2msNhPfO421It+m/h02bKF/ol0qGS8B2l72JO X-Received: by 2002:a63:a18:: with SMTP id 24mr31910485pgk.332.1557153574712; Mon, 06 May 2019 07:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557153574; cv=none; d=google.com; s=arc-20160816; b=MWKVlXcFq7SYny6k9afpDo6n3abGASUJ51zAx1tJNjiw7lQM46KfWI62yn9NCy4SVj BFRw7xmJwQY1lZ+Yh1SrQh2Ljv1M+kPwEPK2TX39/oAV6wx/c/r0+CfxrFVAfBeqH/bH 4TKGT6/wJ95yitpA4z+VkL2QAJbLi3EmJ3O6ma81VesiFH4kmw0ARVAjUmUTrq3yFtVB i+At3Lh3oBgqpiKDh1Ks0ECQKGrtowG0cn8oaaKaziDgIfe4F6xoxra/WH5iRyFRzX/1 XLfMRR6T28LZBKVLJB7+vQ1KGU9eFLvOAyaC0rrC8SSyLMJLNycB2avDdSrji8OoCoET 5yHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UbH1cS218e9I8TxMYYHEk28+Qn7vxjlX2CRGa7D64WQ=; b=sbEo1f+K+rsX2xDQbHBfzzsnt/gGJHSjzkJPuAALRjtoD5WFzaBW3pkCBbkdjbrXhi rOQV/Bv0W8T5G2O5+xzeDHiu6rJZSkOmGH1LHYYjwoTNbdaPqOGErk4lJjxuwWS7REEl 2kuwkNJMTpP3qCB5ZQLISehYlA6FmOdt0lYJkpn2J0YTwFPA7gC92Yu3khaXEyMjek/J ZPVuh6O9RtLtn3KMgMFTT6gzgUjWKlFK+VT9LyCNmGHTKB5neNFJF8UwDo1J6dSJhNCx hmaA5ID+PL4V5z/rzkYXpyBVYUhk1NBYfRLDTaNiPokamOt65S8N5EDU4spetDB7FyHM HMOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=epVBLkri; 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 d21si15015187pgh.255.2019.05.06.07.39.19; Mon, 06 May 2019 07:39:34 -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; dkim=pass header.i=@kernel.org header.s=default header.b=epVBLkri; 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 S1726593AbfEFOgS (ORCPT + 99 others); Mon, 6 May 2019 10:36:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:56598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727127AbfEFOgQ (ORCPT ); Mon, 6 May 2019 10:36:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6896E20C01; Mon, 6 May 2019 14:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153375; bh=nGmKw7oEcz7t/3WCPMGsy5WKp48TzXsV/M5wENwuxF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=epVBLkrigMyU8yd/rTfWbJCp237oS4STsAq4ZX5V8ZENfpdf4SG5DA82CT59ptYT9 OSeLHIrs1vIZNlmmhIWt1/xVWEcQiSFh/dGrsBJqCDGzvd2u4ZWQKJILrnMcWSHedf rg/E02vx2jUYUO/H1LBQ7Q7xG5pTSwN9RzszJbqU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mukesh Ojha , Peng Hao , Ludovic Desroches , "Sasha Levin (Microsoft)" Subject: [PATCH 5.0 065/122] arm/mach-at91/pm : fix possible object reference leak Date: Mon, 6 May 2019 16:32:03 +0200 Message-Id: <20190506143100.794247114@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143054.670334917@linuxfoundation.org> References: <20190506143054.670334917@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit ba5e60c9b75dec92d4c695b928f69300b17d7686 ] 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 Signed-off-by: Ludovic Desroches Signed-off-by: Sasha Levin (Microsoft) --- 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 51e808adb00c..2a757dcaa1a5 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; -- 2.20.1