Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp69144pxb; Mon, 13 Sep 2021 13:10:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb+uS/tQCOou9E4UgwEQ1DYmcvEPZgE6Bm7/yvmiW7fWEBbi9q2RGbYVhzi71Ux10WsdTh X-Received: by 2002:a05:6402:42d4:: with SMTP id i20mr9481015edc.348.1631563837361; Mon, 13 Sep 2021 13:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631563837; cv=none; d=google.com; s=arc-20160816; b=lbfLKIa0xybe8hTXRXz6F1IhGI0LXGMFRGXs2mmTCvG0Pk31W7V1TCESfUqVRX6fnM RMi+BiO/U7g9tMkYmIrmtm0SqWZsx+5udJO0ohTa2ITbim+sTnaRNhcpzDsLr+4nI0fq soZ4cmIT0Q/i5T9CDr8FuczcGzvYXhEJ/XVyUrOkkfS38etgwNPI/FHH2SVbh03Rwac5 vsP4qOt4eZ4bIK5GmWJR6COBNfr0JzyZ5QQng3yoRhPSSscutpr61emkdi+gkxScFrAU LJ+q6xfMrXfI4BMHotSxmzCSAoHLaeZS0GtLbWJMVWHRprxEGkVJWPK4qm/BKtKk0biu TfcA== 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=XBXE3Mmjl3ExYuJHh/6TyBHAYnXn0YQl5OYBPvVNGV8=; b=ET2d20rvbbpJd7P8/bZb3iz4a4wBoMmN6oQUSzNHcMyIxe4aalutDLUErbnQpW+n5N S1Sf4PUk+fVspugKjJ7gLG4rlUnZD0iGC5y9rBLiCYRxF8r0O+NHwXJVTKrbeAy2V8+5 RNMEh5RfAnNF1UpYHZfT1cKwVlYhL6jSQwV5TfOuSxavASBGfwFmO5BftHAgMGqzKEv0 54pPcxXreycRm8bBp8AfK95TgcLXJdSTmm7yV/9+DXDoKF/GTfurh7u/57tQINQx9yZv KuNein4WYAnBmhXHgVyzziI5nAYWIyK5nXc/FG/8aPtDiG07k1vP8xbgQbuuaLXtC+J4 97OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KeryaJDi; 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 gx12si7811784ejc.724.2021.09.13.13.10.10; Mon, 13 Sep 2021 13:10:37 -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=KeryaJDi; 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 S244315AbhIMNtS (ORCPT + 99 others); Mon, 13 Sep 2021 09:49:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:51840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243759AbhIMNoy (ORCPT ); Mon, 13 Sep 2021 09:44:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CEBA4610D1; Mon, 13 Sep 2021 13:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539882; bh=BtW4cQeIHSdudJx0MWJQm4N107xVuA9XacIb/Rm5L4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KeryaJDiubI2SbRP4CqI1/CgeB1hTdNN+8WHJE/SrWgxY7TXoeGmpm+7DHBOPaM0i yY1W8K0H5RoDGkcM6RqRfm/IrGkfPiqv1X495hworD00Kp4QrgjtIBK8yR94bjcGMh FPekKeNhXZop4nvUk7Yurxm8n1DEQr6xLWcqiKaE= 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.10 171/236] firmware: raspberrypi: Fix a leak in rpi_firmware_get() Date: Mon, 13 Sep 2021 15:14:36 +0200 Message-Id: <20210913131106.188906537@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@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 8996deadd79b..1d965c1252ca 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -322,12 +322,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