Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3403167rwa; Tue, 23 Aug 2022 04:19:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR4FZHqUSMQE58/zs6zO/xz7FohtAmVlq12aOA0Sl2EdLsS8XQUbNxvasFw9D0kxHKKxib7y X-Received: by 2002:a63:bd49:0:b0:41b:8a07:a6ed with SMTP id d9-20020a63bd49000000b0041b8a07a6edmr19824487pgp.124.1661253540477; Tue, 23 Aug 2022 04:19:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253540; cv=none; d=google.com; s=arc-20160816; b=zd0soB5cK/Y2RWYCj8t0nAQ8WFxabBlz25wQ6B2EMTfFEtpLt4wkBV8nZLyXZQCu0c +VTAGCMmhYa4kvgLh/8yusn/L6lpgPxT3U2qoZVl7clmOTjaQR46hXi8yXpZIKE8bbd0 O2xyy4bPz+yte7dhpbFu5iV+jzkNFsC1qH3PP22YMU66o1jonzCEA1bsZlkf48VxUUej iFCIL6VwzpzbWezGl37S3E+bskHAQdl0L/UrPP7r/dVU9T05TUk7XSfdf3kDHBEQ1dTm v9sspWs51je5OVNot1pLwzWORDZwSS8cmMq/XNeq3AH/6IW+Ip09Tt9uNaq6h33MTvYY llQg== 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=8AS1nFHYjKjdA66hkVYkvV+dE97yM2OkR0VMlnAUbX4=; b=f/vBq/2f31QVExQmgv7Oe5whbKc9WHt2r4lBs9P4NQ7cfgmD5EVkeUSkMvOxGRolBs fzMc6vnWYCOLsbP4UGYKyTus2qy3fSV/76UF1jBIPug/Od5uc0MlP1jqKC5/Yr2YOBmr 68WVh5RznwtR+5WBL0wXSOVJTlX7ybuJOpteuSiBCv1aDFre+W5WHB3ZAf5AvBFkD6p4 zEfzAuGP/wmvlmdBgtx1FvZs/lwqoXOWbTBRT2ocitk6KydoqBvKBHWiuswx75CLYSGX joVhWw1/j88wSG0m6HaNLRZmr+Vfrqmw2cFRqw7/eYSoJ8DKaS1NUn+AlCyiNmHUy8kn MXag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o3iyk5qf; 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 w18-20020a1709027b9200b0017280be5a02si13495534pll.589.2022.08.23.04.18.50; Tue, 23 Aug 2022 04:19:00 -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=o3iyk5qf; 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 S1356418AbiHWK6e (ORCPT + 99 others); Tue, 23 Aug 2022 06:58:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356807AbiHWKy6 (ORCPT ); Tue, 23 Aug 2022 06:54:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27D4F17A80; Tue, 23 Aug 2022 02:13:24 -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 EF7ADB81C35; Tue, 23 Aug 2022 09:13:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F632C433D6; Tue, 23 Aug 2022 09:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246000; bh=WONbyPd92C87yD12AFBp86wxDUVPadaQjeI5ARmuaJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o3iyk5qfE7c4qpFXsaK9KH9rPmS932/b2Z7ELHS2kTonhalOFPGIWpZ6Tnw+OMlud AJ9eDPDEu9b90K0OrkZJjGNWtQ0XaijmIcgmS7m7fF8ZVJD9Ck7NL7+nhtRtPyJHMq tXx1bAhHHdqx/1sJIWjGWUDNPCAOrHdU8ziDS+TE= 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 4.19 257/287] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors() Date: Tue, 23 Aug 2022 10:27:06 +0200 Message-Id: <20220823080109.922330877@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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 1887473cdd79..9959522ce802 100644 --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c @@ -141,8 +141,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