Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2932733rwb; Mon, 15 Aug 2022 14:19:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ZF2fIeaGdWYyn6AL3cNTmjh8bppF8Cr8cSjgijE0jp4HWrr97pZzqGAHHQpM64BGsmk2f X-Received: by 2002:a65:6052:0:b0:429:9cea:dcd8 with SMTP id a18-20020a656052000000b004299ceadcd8mr1033855pgp.461.1660597957635; Mon, 15 Aug 2022 14:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597957; cv=none; d=google.com; s=arc-20160816; b=YXNOpWxdqN8u1ZDRhsv+G4hGMIcECZSWJe9nmeX9F4IH8KffiNA3Ve/FNu6l3e/WwX D17r+sZy8yKiufdj79AKnFt71vqdquAdlplvLRw0a3M6M1OvHGiwLxZm7pgT+Aoh6A0A sbx20p3pshYu7Hz87fHquYA00lwjFEvwd2TJpD0ku+lVeTqzA6rsYjkAF3XF/UjrY90U GptNjwRQ1GA58J0HXKOrLGAYf8sdN6soA3KE4RQIP5MgPAaClVjNaCnPqWW2yIyDnhR0 IIkcZl63nc7k/sniqYRSqpJpf+j6xog9HTG9jFAYI6j2YXUe5XEKg3o5HCwLG2p5Achh 1OsQ== 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=U0VJ7xEidKexETUxthlTzMUaBxSQ1pZ5ELbym18Lh7r/GdW3yHyI1+DiHO1905z2g4 l6CGLqLyKZCIyvWYzp0oBAwSUp5aLR08Z+fIO+dGfeRhp9tNfuA+qqzc/J+pvCOKsNBw NcZcDaZDYWZllmo6aVXIMpwstDQLI29GG35Rt2C0Tys9wRZCWGL0CWi0BnsIZo2tG4o3 +LXFO9ZrLIW7JyEBP2IFd4x3Fq1x86SrtQEnaqpsPArepLWECtTFenRsdLlfVBjVzdhY rjEoYLEHSeJ/tiDMc/05gPKi7E9oE51E55lfQK7TAnQgKVJV7HSAI/0aeWZw1wuOuseF RptA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wewEOf2p; 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 r16-20020aa79ed0000000b005352c3c2db5si370649pfq.132.2022.08.15.14.12.26; Mon, 15 Aug 2022 14:12:37 -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=wewEOf2p; 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 S1344850AbiHOTpL (ORCPT + 99 others); Mon, 15 Aug 2022 15:45:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344932AbiHOTl4 (ORCPT ); Mon, 15 Aug 2022 15:41:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA5A141D18; Mon, 15 Aug 2022 11:47:45 -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 ams.source.kernel.org (Postfix) with ESMTPS id CE430B810A2; Mon, 15 Aug 2022 18:47:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CC7CC433C1; Mon, 15 Aug 2022 18:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589262; bh=vo0TAGeRPJNhuCFG7rNuv/V9pYpe7Wt0kisbfUGzm10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wewEOf2pMdtJ3GIVvcz5Nt1BmwxhYDNnz4+E3+yWYSpc9XoBb7Viwf9afkZ6pox37 MvRzspHFxSsVtCimS4MaKUoqUKo5a8dUGFiA52gduHPV80yo3f/U4lwOPmuC/34HZd zMpJtvPznpq4T/BKC+DFO4iMVGgLTCjfeKZPdvaE= 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.15 632/779] video: fbdev: amba-clcd: Fix refcount leak bugs Date: Mon, 15 Aug 2022 20:04:36 +0200 Message-Id: <20220815180404.352870143@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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