Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3353207rwa; Tue, 23 Aug 2022 03:25:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR4lkxXbwuwsHth3Glnwo99Z/XIqf4R5PMOsT+a5SjO2ZZUV/vZevvHWHKMoAkw8k9Vltx83 X-Received: by 2002:a17:906:7c4a:b0:73d:9279:2c42 with SMTP id g10-20020a1709067c4a00b0073d92792c42mr3379460ejp.597.1661250306218; Tue, 23 Aug 2022 03:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661250306; cv=none; d=google.com; s=arc-20160816; b=EdL9AKAB4p4CpILni5SottzLM9AvEVrTGKQDJC5H24iV+qCeswSoLxH74DlD+xUltr EMeWV30e6LgcNBxfLzgPkFgYqYTzSB8hrLZl3oDlJUPREhq/B2w1kTsfheso3S4mPcoo PPlvCpLEc+BOUxbesRBtCPc/wubpw18OTn8KXJOyhDw2CeZOp1P972eRGPJE8npWYe/P 1Na8gEnHFDtFyUi31VTS51oqigCePXZ1R+L992khLMtz5H3tx7NZTv9Hs9ojcFDpzKi/ cXw7+OTo8PWu8Q8CAIT/fdhDO9l9Fn8oO64Me5enpjZPVicww53j2daUF6JbEi433LWN k06Q== 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=tXOxFr9lnjx6quLaCkkwJi+l3IPL1qSIDBuZT+gIvTQ=; b=XgRHB50PKQfo2o1gGIu/BRslIFI2N0atRnFEaELkvpxa33VKvr240ppwV6AeSU6mGp u8n4Sr6aBv/CFjLkSWRW60vyvFKI4wy67Gdsb/LyYQoQyTvpAdjZoNHwzDSm6aUlxrb4 6nDtrSe5DXyvep6FLlMyddbGkJKXbnTJOvm87cOMc1ojJrMWJsSJK61gvLY3hKvhL1Zv EHvrg+7ksUKkrxCsItyzURAOCSEhCM1JwTF06/VdZCfYWQiL68eqsMWv52ZULD5tZJjN wxfYls/FTU2VyP04YOudPie3ESZomS7USuqKgVhQORetmMjveKk4ah0ds+giWtmVNyuA PydA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j0vdfaWX; 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 ht18-20020a170907609200b0073094ce02casi11539826ejc.791.2022.08.23.03.24.40; Tue, 23 Aug 2022 03:25:06 -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=j0vdfaWX; 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 S1354249AbiHWKVC (ORCPT + 99 others); Tue, 23 Aug 2022 06:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352885AbiHWKJ2 (ORCPT ); Tue, 23 Aug 2022 06:09:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041547D7A0; Tue, 23 Aug 2022 01:55:17 -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 82CF6B81C35; Tue, 23 Aug 2022 08:55:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1856C433C1; Tue, 23 Aug 2022 08:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244914; bh=bN3EKTlsIxDcvLIM4ArOYD58V+iKRrzDHbCvOFH9Ogw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j0vdfaWXkCSzGDH9fcwtxgJQqF+PqtR7W+gn0yVUYt/ydqx6RMeJElwq+Ra7uFteE o9ntCAB2zl/LbUi0pHe3HgskvVkBS/R4fyHX+dOTFb1Gi3AsFMYReQGebn1tDmAty1 FwGyKDb6rHfBaDELUsC+4UEre5NK9qAklzAe/RT8= 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.14 211/229] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors() Date: Tue, 23 Aug 2022 10:26:12 +0200 Message-Id: <20220823080101.180969502@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 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 2d5f2ed3b0b2..0da33f7af654 100644 --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c @@ -136,8 +136,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