Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3023811rwb; Mon, 15 Aug 2022 16:21:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR7YIaW44TBQyhnvWWEExpJ7CWuAKdGG9WYtCiH7eezkHVqaEjWa2JurCp0M6ml/1hVQ4Bpi X-Received: by 2002:a17:902:d492:b0:16f:8583:9473 with SMTP id c18-20020a170902d49200b0016f85839473mr19690563plg.103.1660605588155; Mon, 15 Aug 2022 16:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605588; cv=none; d=google.com; s=arc-20160816; b=Gd/cuxJjNFOOdnM4CzdZjwYvUbiQd238MbX1e+VT1pf9UCvuJI0GFIfDUetqDlYDjY sB06m5NnXJ8HA3mUwl76LBfmYFSkMMpBm0t+PH6KFWGupwSlm7Y7J+J5vmpyrwFbObgY +AdGUbT62gUBjr15d/pcsfMGoQ8IaKb3vrCdg2WVRxc9eSvN2ic+uSPU4Jt61zzIGiq1 5veGZ1eVOrjxg03dtdacLlnSs+ygPBk5enrTTjZyCmWwNzH1fTnx52Hr394I5mjLfMYG Hpu1LFOuPHo4KynAFPTeHeoXpZA6Q3sPS9WaETZCtalEcLddmsZCzLK/Cj7AbnTWFNHz 92FQ== 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=5uzdM0Fjqg+yH3UhiRLN5RuvjHn+e55ZuLHl3tOJFJo=; b=hW72CQzkqv2dXYbUrhTyX6dzjxpSQKjvKAqCAIL6HitoGXhfYTVpWSO0LzDyxQaAta G6GOIQMkvmgn3y8+clEIsZxwqWZ8KswAMjZDR7YMG3GVzEx2CdcT+KVUCuaHohaVRiHr EDobmSKKiomTq2TlpRLb8Yp1GR/lewgjFZulbM37DlRn3xKfSspkqRdeGExpECcGE/sp sCE8HNoXi0301+c001ovnZh1AnCcc2vfZi8EF+fde2ew4VuOi0JXbMON/Hh0leU+tSoW BDKTphELyTKqxF9a05V780/ygs/r/n20tgn0CxCkxiZsYkIwITUZTJSNlU7M3G+Nioz4 7Qdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VXqOxrIX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 23-20020a630217000000b0041cefab5b61si11795947pgc.719.2022.08.15.16.19.34; Mon, 15 Aug 2022 16:19:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VXqOxrIX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1351971AbiHOWuR (ORCPT + 99 others); Mon, 15 Aug 2022 18:50:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352189AbiHOWsC (ORCPT ); Mon, 15 Aug 2022 18:48:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C69D37DF60; Mon, 15 Aug 2022 12:53:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A6A4260FB9; Mon, 15 Aug 2022 19:53:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96A1EC433D6; Mon, 15 Aug 2022 19:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593212; bh=vo0TAGeRPJNhuCFG7rNuv/V9pYpe7Wt0kisbfUGzm10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VXqOxrIXx3oEUVvfQ74LZS2LROyAvxrBQ495AYqKxxzIXB+kkAF4utxGkc5HRmaPQ o5M+4OpLa+koFlYWHUyZaRQwqBXuE4mDbd/3yFDEW9BnxJf6C0ny75pI5Ej9k3Ex44 CuGwHn+cAI366MSgFSzv4zD/gorvcAOIbozIigrQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Helge Deller , Sasha Levin Subject: [PATCH 5.18 0912/1095] video: fbdev: amba-clcd: Fix refcount leak bugs Date: Mon, 15 Aug 2022 20:05:11 +0200 Message-Id: <20220815180507.015333870@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liang He [ Upstream commit 26c2b7d9fac42eb8317f3ceefa4c1a9a9170ca69 ] In clcdfb_of_init_display(), we should call of_node_put() for the references returned by of_graph_get_next_endpoint() and of_graph_get_remote_port_parent() which have increased the refcount. Besides, we should call of_node_put() both in fail path or when the references are not used anymore. Fixes: d10715be03bd ("video: ARM CLCD: Add DT support") Signed-off-by: Liang He Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/amba-clcd.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c index 8080116aea84..f65c96d1394d 100644 --- a/drivers/video/fbdev/amba-clcd.c +++ b/drivers/video/fbdev/amba-clcd.c @@ -698,16 +698,18 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) return -ENODEV; panel = of_graph_get_remote_port_parent(endpoint); - if (!panel) - return -ENODEV; + if (!panel) { + err = -ENODEV; + goto out_endpoint_put; + } err = clcdfb_of_get_backlight(&fb->dev->dev, fb->panel); if (err) - return err; + goto out_panel_put; err = clcdfb_of_get_mode(&fb->dev->dev, panel, fb->panel); if (err) - return err; + goto out_panel_put; err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth", &max_bandwidth); @@ -736,11 +738,21 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) if (of_property_read_u32_array(endpoint, "arm,pl11x,tft-r0g0b0-pads", - tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0) - return -ENOENT; + tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0) { + err = -ENOENT; + goto out_panel_put; + } + + of_node_put(panel); + of_node_put(endpoint); return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0], tft_r0b0g0[1], tft_r0b0g0[2]); +out_panel_put: + of_node_put(panel); +out_endpoint_put: + of_node_put(endpoint); + return err; } static int clcdfb_of_vram_setup(struct clcd_fb *fb) -- 2.35.1