Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3408518rwa; Tue, 23 Aug 2022 04:24:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR4CTFp3gGWzMg+qUDeAxbhZAcaoflh3v4sbAa42qN24ArFQj0Q7xh8mF6RUpYATrFnywaqQ X-Received: by 2002:a05:6a02:10e:b0:42a:b42b:5692 with SMTP id bg14-20020a056a02010e00b0042ab42b5692mr7694416pgb.67.1661253861102; Tue, 23 Aug 2022 04:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253861; cv=none; d=google.com; s=arc-20160816; b=VQJ6o3Khx+ZQ4iUtzpH/tLfIyhVQnyzsLXhXBJXFURISZHQdDtwD8Q1mznOv1Ysi3K W3j5UJhrG1GeFG/h2KTxMkReq+SgoMkToGajG+8XjP2NfE+FkG5CfnR2V3bYneVwQl0J W2KFu/knhKyUI81/FParpY0U6nFY7iwT9jtbabqO05yU5k5qi7AD4lTVVDWBF08sBv8/ AaHTS+vsu04al2O527QBuNI6XgLrREehqgCIIuCp0hNgy0sYlKE7JkEIF6vZsQtVfet/ oq/lDW95MudcHvWwPEHUsmjvwutXHB+mptMn74A9nyMxOA8U76TqlTMymwYrGX8v6zGj 4pbw== 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=K9Y3551WpOJoBzvn1ZdgjTRSkl8sosm1/7EO2zktmGo=; b=ZzTwnkSNdkx2qmxccwz3egxf3vRK34FNRiYiuVBU8VCpcqUuaybuaiR+IHP3nvJFHh FGQKBEmsenWbpE+QLU28aBJwEyIFJXU3zBqM4S3SLfVlEWzT4qt7Gdm1cI3Sat+7BN+A Hf2b95/V7jp7mzI0hb9WMGwe4E/iYRcAXLwMvkhHtfT34zWjfhOzN9i+2hfS45fNWT1x tZQov78ga5H94dCnQO0Bp8XiMpQz38WR6ePwieh8hC7cd04erVsx85ZD0EXaLnxU5ifI 7Ngysm+dGQvermCj/581VapG2sm4dJh5jJEsLUzhYxaBzgFyb4RZtlM8DkgMLSOfxULG N7Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cch7YNp0; 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 d2-20020a056a0010c200b0052f44beb0d1si14289518pfu.291.2022.08.23.04.24.10; Tue, 23 Aug 2022 04:24:21 -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=Cch7YNp0; 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 S1349259AbiHWJ7u (ORCPT + 99 others); Tue, 23 Aug 2022 05:59:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351921AbiHWJ4H (ORCPT ); Tue, 23 Aug 2022 05:56:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 646A8A0243; Tue, 23 Aug 2022 01:47:01 -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 EB304B81C28; Tue, 23 Aug 2022 08:46:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51856C433D6; Tue, 23 Aug 2022 08:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244414; bh=UvjwmRJ+Iy/3UibiCRCyZWexNjPggbBD70mBSvpah3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cch7YNp0T0TL1qwWTO2jQXngLa0XirO+TvBjGM0AV1Hhs2jWlo9i7Ezxrj7PgSraa qoBHl6stNoNAfitU49efz1Gu+5OM/kk0xkXKbJ8mrmL5d7R5o//TnEbA6CBUeWgEg3 FwZSQtZe5blEGkapCVdai+fm7QxgmmDlIcwdHTAM= 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 4.14 134/229] video: fbdev: amba-clcd: Fix refcount leak bugs Date: Tue, 23 Aug 2022 10:24:55 +0200 Message-Id: <20220823080058.486095665@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 66c7d766e330..6e9c40cd820d 100644 --- a/drivers/video/fbdev/amba-clcd.c +++ b/drivers/video/fbdev/amba-clcd.c @@ -772,8 +772,10 @@ 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; + } if (fb->vendor->init_panel) { err = fb->vendor->init_panel(fb, panel); @@ -783,11 +785,11 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) err = clcdfb_of_get_backlight(panel, 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); @@ -816,11 +818,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