Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp153229pxb; Mon, 13 Sep 2021 15:39:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6OGSifAAN7VclCB0EGHMHuoAJ+iTjfmyUVJJxMFR6B3P22rDc5YbjIb0uBSYjVrI8xX1F X-Received: by 2002:a05:6402:27cd:: with SMTP id c13mr15622791ede.266.1631572756139; Mon, 13 Sep 2021 15:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631572756; cv=none; d=google.com; s=arc-20160816; b=uDouf6mcc4rGJA2Rs62ZW0mzushzU5V/2TU6KxzcK/5u/1Cdz7s71mBx5AGJEeci/S mRxPRhxskkzmnLDZsS4AvSF3dBXST14q7pHzCTjMIR5RHPxIDSF9CQlhRdXDzA6rEm4q DTh0RCoYNQkAeMZ9gzWjQwadyxSACdExNPTSVwbAF+vLFWrKVBua4mrcRvmaFkqaVyAQ 5kDy4flvx7yiwD92Z4AfUNohRmI+DIAizK5YL3fdJyOW1S7mpfxHH68ptgruaTswgmfI y9nXIaj0gJktlfjcBPA6ADPh+1RyhgBthHUmMLfSb5thl9s4122SAIITXerh04/l1Bph GBmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pA4vyj5z7qLnGK8zNAMU5SEr3vNhEDt3Puojj/PY1z0=; b=0YhCSfxYVKn54W0dqjv8L+G0oZfV9CtnmZO4veqxtzpFsBE91H21CDWp/Avltag3tv Qr0WcjSa4ddacbwdBeGPW7VixYqqjcvCYppLQMiHg51kwyBK24BCQO7OYQoDDDzuXN3j 15+UgazAqB93Ti5d5wV6NQmZvF9sFe9IvjhhSFRmQIDzquKa9GpkF0aLjzW9z9CIZHdy ATNG4haNrZnTh0qnedj7k46RRSCFkyq4ogKC56LjZ0B4RfpDw6TCtkzFozlrr9W7FP8U 6s0L1cHhxHjA75tofuT02rMBc7x0zxTtPBOrbwqedpvlJu/CwLBwaAaAU4yTn9qBVn2S sYSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RMS9SvlJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si11436068ede.473.2021.09.13.15.38.52; Mon, 13 Sep 2021 15:39:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RMS9SvlJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343618AbhIMOMT (ORCPT + 99 others); Mon, 13 Sep 2021 10:12:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:55994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243278AbhIMOJK (ORCPT ); Mon, 13 Sep 2021 10:09:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1F393613E8; Mon, 13 Sep 2021 13:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540469; bh=jRPCEKKYWg+2r3Q55PnmcsHoHzvghlYmIOUah78fWJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RMS9SvlJWh452zZ7QB27Z97oGtcHlbAUlWmDMREBABPfJK8gVpuiacRqeyBaP1Rvo UokRY0LQ5PUMxOsqcjHpbkcjc0bH5Jj+9m1pjBDOqjZKRWFB6sKmgwesYIGtmU/8ol BCO+FTbxGAIK1lkWxR2ZdORl16yQp9k3HVvkpZUw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Sasha Levin Subject: [PATCH 5.13 207/300] firmware: raspberrypi: Fix a leak in rpi_firmware_get() Date: Mon, 13 Sep 2021 15:14:28 +0200 Message-Id: <20210913131116.361498755@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ Upstream commit 09cbd1df7d2615c19e40facbe31fdcb5f1ebfa96 ] The reference taken by 'of_find_device_by_node()' must be released when not needed anymore. Add the corresponding 'put_device()' in the normal and error handling paths. Fixes: 4e3d60656a72 ("ARM: bcm2835: Add the Raspberry Pi firmware driver") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/5e17e5409b934cd08bf6f9279c73be5c1cb11cce.1628232242.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/firmware/raspberrypi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 250e01680742..4b8978b254f9 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -329,12 +329,18 @@ struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node) fw = platform_get_drvdata(pdev); if (!fw) - return NULL; + goto err_put_device; if (!kref_get_unless_zero(&fw->consumers)) - return NULL; + goto err_put_device; + + put_device(&pdev->dev); return fw; + +err_put_device: + put_device(&pdev->dev); + return NULL; } EXPORT_SYMBOL_GPL(rpi_firmware_get); -- 2.30.2