Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3416760rwa; Tue, 23 Aug 2022 04:32:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR5isz48bGKTpYoONSH+EVVa2APMrGf0mdtwJ5usKHRrM2cofbqTHxT42sdIis7byZw4u/mA X-Received: by 2002:a17:906:844f:b0:73d:56b6:7e3d with SMTP id e15-20020a170906844f00b0073d56b67e3dmr12399182ejy.545.1661254373446; Tue, 23 Aug 2022 04:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254373; cv=none; d=google.com; s=arc-20160816; b=xsyWVXXnGYG2M8FlBE2Gstu2CQC64hGJV5ZIjlFXulYqhPf2uM6a1LE5LVN2aQgqlR vHdWBtTHLpILBjKeywfovSuwGUudUn2Agt40F0yhBiWvJEbA0tf5uoCsknEbg86mn6YU lR1t5t9YWFLK8mfLsGhL8vGEHn03OzNxmzlYfNCAp9u5LP91L4f0vj55O2yXwXN8i9Ku JJN/i0HD/Py2n2ZI9RORyZnEd+yxNGpZu+CFTZ2EZFnQIKO0PyerTBNrAtfDsLk1D6G5 b7hlia8+f1NLdFIzzJWGJeb6WYPSBmSxrAZ8TMNNFY6VFnP5cAOfoxFawcRPPLbOlM4f +ByQ== 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=7heJ+UVBx7WOAVUiAjrK4Dp8tbNlV7XJgeEyTiXjkNs=; b=aX1OwW3HycriXkaQQ+pDmCOppgy5DspIuZVR0WLlzSZlyphK6zXeXiwe6TgJwD4di9 zYuXNI5JlgQC5VxQ32nDixG2Xu+v4TKJ4b0P6geUJtaZgHhJclGiKzBXHG28GQ3aFmWt eSlTWk6mgUwr/21Yi2wILyB3R1NAH3ofd32ZYrnnzqeqcvzHuBZZMrLRjjPBn0jJnoQ7 zKlAKGtvSXEDNdWooV8tmeboXQXcId/wnFd/EcgZCgFYLo0ddlac+MZgL0Bw42t1MCRi ik1vS6jR+a4qunszpuSZ2gCXSPiUSjE/9qfgWJOYKJ/UOkBohYn+4V4gFmU1z1UI5kIm wzTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hAez04SD; 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 y9-20020a056402440900b00445f21c2b32si2420453eda.132.2022.08.23.04.32.26; Tue, 23 Aug 2022 04:32:53 -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=hAez04SD; 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 S1353864AbiHWKQH (ORCPT + 99 others); Tue, 23 Aug 2022 06:16:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352938AbiHWKGa (ORCPT ); Tue, 23 Aug 2022 06:06:30 -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 BB91511177; Tue, 23 Aug 2022 01:53:40 -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 54D4CB81C28; Tue, 23 Aug 2022 08:53:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B9C9C433D6; Tue, 23 Aug 2022 08:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244818; bh=a/tR0wRoyr4JuYKwTcIB1bxG4Gavs+wVKA4M6lxPakE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hAez04SDu9ICXZugcXse63g5lwsda5/ZKDRtMqOhmZvfRnwn52efAu1Wzc7MsFcpi BqVdKWj94STythVjZc+017i8jJAxUypIJiUHilfcirRE8yRYkXMaq/lBnG+atkrrQc cZy9067jGMqJFP/pbBAlSgsb3APbi2jlFuDuf+1g= 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.15 157/244] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors() Date: Tue, 23 Aug 2022 10:25:16 +0200 Message-Id: <20220823080104.437021684@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@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 c98525d60df5..a56607501d36 100644 --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c @@ -114,8 +114,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