Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3295343rwa; Tue, 23 Aug 2022 02:10:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR7uOPdQXNPOTTpulaSMmOVz2mVMII7KuT9SNLedhAV/kdggHF/AgO9v97mGicETVqPq7/dV X-Received: by 2002:a17:907:728c:b0:730:c005:5d93 with SMTP id dt12-20020a170907728c00b00730c0055d93mr16017059ejc.265.1661245857235; Tue, 23 Aug 2022 02:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661245857; cv=none; d=google.com; s=arc-20160816; b=MIKDfypM7Heop0UDPhRuhexDNIh5kVOXXLWHbgri5jSVGW91iWm/NI7B8sHqX9Yj1h ZUS9kv5sSe7CuA7xJpQaiLATyrFnJkTDManSGg3vV8ra/+hr6/bUTTUdrndb1wviNpjx 7u40Dw80i4EFFPCke1Ija0TZV5opUmlJahOMWJmgAP2EzXrP4hB9vQrMDwPncIRM7DKw tPThY5BZOE+XQkuCYd2e4R2qVTUbrip4c3lBm0ir/QKIMX1thTWCchJ75ewMaxnHXWuS 472UvRSYMKKePzG28UrEVNjY/Ba9qF5FtBKPBF3b1r42pLLr0lII93n9IWmgsL4Z1kUI WjjQ== 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=dmyq4tbQXflgCG1TaE+KV9edkH7X8YfvSMw+ZpjAwvU=; b=gi9IsF3KVv5IKRDOovWnU/ERktPXm/XCrJqC5VUkSBMjfd8HlmPzP5wu7PIVUW516a G7R2/SQ6nM4WUCGbG+Z6lexwsmNoFtf8WNhyJc4HpF7or418ksBJ9PDecpnRq5463/y/ AKFcQQhauClpCk+sQyml5u1Mb5haYwsyNSD98H49QW24XrnR/7PuIejdzdvWlQ6V+Nci LKyP1qKNz5UymhnmsG4ZiQYTe+eWWelzgFJCgdG0O4OmWS86btrHN7qHn30MrQ8O/mt9 3BQ8FQMKkk7LZSlhkXvEpsZ7Eh0jIFe3OHh112MPkbBkQBN/yAFbbbHHqqO+h85vF/GG 7blg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qcNwR7KM; 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 x10-20020a05640226ca00b0044674c30374si1867508edd.135.2022.08.23.02.10.30; Tue, 23 Aug 2022 02:10:57 -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=qcNwR7KM; 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 S1347967AbiHWJHX (ORCPT + 99 others); Tue, 23 Aug 2022 05:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240664AbiHWJGB (ORCPT ); Tue, 23 Aug 2022 05:06:01 -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 CCF6885F83; Tue, 23 Aug 2022 01:29:42 -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 E5042B81C55; Tue, 23 Aug 2022 08:28:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52295C433D6; Tue, 23 Aug 2022 08:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243328; bh=K7ahQAN1O3DYTL9J9OrKOMX8MgIAfw6ui3rxdDEwoMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qcNwR7KMhVgi9bQg89hKUo46GlDe9ZWAuhKlot2AgtZ5tnpwXYkkdDWO5EBvLMcjh zXaWllFuq27xLiDgM2NwFf6ap3UROE1Pr+FN1avAFnACHwpgG/g95bcRNanKAxQbrx cnM4Bnn4KGROI1yBgMpcq/Pqkugi7vkWAfwEhhvc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Martin Blumenstingl , Neil Armstrong , Sasha Levin Subject: [PATCH 5.19 243/365] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors() Date: Tue, 23 Aug 2022 10:02:24 +0200 Message-Id: <20220823080128.399413304@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@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 91b3c8dbe898df158fd2a84675f3a284ff6666f7 ] In this function, there are two refcount leak bugs: (1) when breaking out of for_each_endpoint_of_node(), we need call the of_node_put() for the 'ep'; (2) we should call of_node_put() for the reference returned by of_graph_get_remote_port() when it is not used anymore. Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller") Signed-off-by: Liang He Acked-by: Martin Blumenstingl Acked-by: Neil Armstrong Signed-off-by: Neil Armstrong Link: https://patchwork.freedesktop.org/patch/msgid/20220726010722.1319416-1-windhl@126.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/meson/meson_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c index 1b70938cfd2c..bd4ca11d3ff5 100644 --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c @@ -115,8 +115,11 @@ static bool meson_vpu_has_available_connectors(struct device *dev) for_each_endpoint_of_node(dev->of_node, ep) { /* If the endpoint node exists, consider it enabled */ remote = of_graph_get_remote_port(ep); - if (remote) + if (remote) { + of_node_put(remote); + of_node_put(ep); return true; + } } return false; -- 2.35.1