Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1458044pxk; Fri, 25 Sep 2020 15:46:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2F393bga6TeIlscx/imf6QHTRhoV9up5h3U6AcEZOdGZmedrEi9gE+uH5O2QGkYy238nJ X-Received: by 2002:a17:906:4cd6:: with SMTP id q22mr4870364ejt.139.1601073974384; Fri, 25 Sep 2020 15:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601073974; cv=none; d=google.com; s=arc-20160816; b=PbrtGA8sWvHATSYnvQXebx8fWeEdANoEhq1H+kSaF9uTXzkCPcwBlJ9lV3JqUxwK2U zIeA9iD9GHUaIUmCcRO8nvMdb1+moDRO1HLSEEjoJz64BptRWO+UFhQNppOngd5CRrAK MIMncl/LtxdjMPzpzmGOOamPoeSygo4iOZwCvBscdnCRAC/o6v+zhguoshGY4evcNiM7 7V5cTk3hLlBbSKNSM+W3Zb9MnUCJOYxdvWSmV9+4AXphK6Bax2/tCm/2Jw0DDRCI1Gfn JbKLOyzLcOjcAhqpKJhXKi/Lkch6Avoi5tXx8kgMKwaFww/57+yIoa4eTpWPObD87zxT SjgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date; bh=7T0BnzJGxG+2hRTbZa3D0L8AeyRpVktNXZ0ZbyZFIek=; b=d5mSg0eZ8WBU83N5M4ZmKbgtUf3+pwdfnGKdoX/nv7bNbCosao2VVtocGbzSXSBOWH P5eYVhRAoidM31yqzu5UJir9eFgzoCkfMxFEV2e70Lg41V+PzIxrXj3FZT5MrQ39oAAp rM8wMdgxhLJ6S2LOlQ35imiZHeCzRABeBpuJw/FN5ZoSL/ijyFb07CNPRzngPGLeJU6z h4aAfXTpYbMoTO71QNnaw4bUyM+r31tolup2IqiCDf/7W+WPsy4y0Sk2c8n5SPV52sq0 BoZuJzZVAU01zfbnV5oFB1L/TvxdjiM+A1ZXrYU/mA5WbBvm+0RYZaemjbS2Ol7l9Jh9 4eFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz8si2628810ejb.601.2020.09.25.15.45.50; Fri, 25 Sep 2020 15:46:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728612AbgIYWot (ORCPT + 99 others); Fri, 25 Sep 2020 18:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726636AbgIYWos (ORCPT ); Fri, 25 Sep 2020 18:44:48 -0400 Received: from agrajag.zerfleddert.de (agrajag.zerfleddert.de [IPv6:2a01:4f8:bc:1de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7A68C0613CE for ; Fri, 25 Sep 2020 15:44:48 -0700 (PDT) Received: by agrajag.zerfleddert.de (Postfix, from userid 1000) id 249275B2098B; Sat, 26 Sep 2020 00:44:47 +0200 (CEST) Date: Sat, 26 Sep 2020 00:44:47 +0200 From: Tobias Jordan To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Laurent Pinchart , Fabrizio Castro Subject: [PATCH] drm: of: fix leak of endpoint Message-ID: <20200925224447.GA27832@agrajag.zerfleddert.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The for_each_child_of_node loop in drm_of_lvds_get_remote_pixels_type bails out in two occasions. Originally, both were calling of_node_put to clean up, but (probably a typo) for the wrong variable. One of these typos was fixed in commit 4ee48cc5586b ("drm: of: Fix double-free bug"), but that missed the leak of the original endpoint and also the first error path which was obviously wrong as well. Fix the leak of endpoint in the error path by calling of_node_put on it. Fixes: 6529007522de ("drm: of: Add drm_of_lvds_get_dual_link_pixel_order") Signed-off-by: Tobias Jordan --- Sorry for the confusion, it seems it's not that easy to get the variable name right. Please disregard the patch sent a few minutes ago, this is the right one. drivers/gpu/drm/drm_of.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index ca04c34e8251..997b8827fed2 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -315,7 +315,7 @@ static int drm_of_lvds_get_remote_pixels_type( remote_port = of_graph_get_remote_port(endpoint); if (!remote_port) { - of_node_put(remote_port); + of_node_put(endpoint); return -EPIPE; } @@ -331,8 +331,10 @@ static int drm_of_lvds_get_remote_pixels_type( * configurations by passing the endpoints explicitly to * drm_of_lvds_get_dual_link_pixel_order(). */ - if (!current_pt || pixels_type != current_pt) + if (!current_pt || pixels_type != current_pt) { + of_node_put(endpoint); return -EINVAL; + } } return pixels_type; -- 2.20.1