Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1454740pxk; Fri, 25 Sep 2020 15:39:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeJCmsh8S8XuFyLTCPdRsB5FEsVIMjyoTJE45vtOoWVJpMGOdOhQzOogXeR20KElZx0cva X-Received: by 2002:a17:906:d14e:: with SMTP id br14mr4630562ejb.299.1601073545216; Fri, 25 Sep 2020 15:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601073545; cv=none; d=google.com; s=arc-20160816; b=T/sD5dakzyEfBUhNFv4XGawluvOidSoExEAVkRwhG1YH0prcqc5P/wzxmamGjFivLQ VRr2Wyvg5NFUcceC6q7xBqKBzeutGJ/guRcwCFQnTJMdoOWAXrxn0co+TjaOEff7JCW5 OF91zTnkqDA1k0k1Yct9y1ANo949MEZWAEbDkv+q9qFG1axuOq7U/SRF9nlsx7o7vDty YHuFaeW9cAsergmPhl+rJqN9uRd6nUg5DngSUTzjZWunoSLJS3aEv7ShzA8nTRr/N6rZ TaGM6kdmDDCLv5aiVigaD0BLh2V2VBJJgSGewmu7H9PeJquh7oi8eX8dR5EOCVHwSNbI mLug== 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=tvNFuqR4Du+UAxTme1dC7TWSNEANkhfjSVTJeeU7304=; b=lNG+QVa3uPJEwy5ZC8CuZEmR0tZTI0kATLyv35sGjWlwduNkmSFzleaAS6LqA+Amzu vCF9vjaBTX6WFCVgdJAnqNFxFxTFrLNbCZzuZq+Z/7j7mTUqZ3poezP9O8wcA9M9DnVM n+IoOJblezRInae9F7e/R9ypkQ8PLj4f9Ty6N/YJKPXW2BPgcbQrlGSLmQ3PcPnjwMfx MogyKaWefFIAR0V3ejo547JloT8WEtKES/49h3mXAgTa5J2aDn+NxQlpy2G0F76HV6qd pM6me1pHLaE6x5kkvPetdfYP24EKeRypEBKcHlL1IQ1GG5fhOf1GiMgChvo0FWS/YDGv JcBA== 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 bs18si2868172edb.597.2020.09.25.15.38.40; Fri, 25 Sep 2020 15:39:05 -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 S1728431AbgIYWhE (ORCPT + 99 others); Fri, 25 Sep 2020 18:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727599AbgIYWhC (ORCPT ); Fri, 25 Sep 2020 18:37:02 -0400 Received: from agrajag.zerfleddert.de (agrajag.zerfleddert.de [IPv6:2a01:4f8:bc:1de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01A4FC0613CE for ; Fri, 25 Sep 2020 15:37:02 -0700 (PDT) Received: by agrajag.zerfleddert.de (Postfix, from userid 1000) id 339E95B2096F; Sat, 26 Sep 2020 00:37:00 +0200 (CEST) Date: Sat, 26 Sep 2020 00:37:00 +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 port_node Message-ID: <20200925223700.GA26659@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 port_node and also the first error path which was obviously wrong as well. Fix the leak of port_node in the error paths 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 --- 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..5c136bd5a671 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(port_node); 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(port_node); return -EINVAL; + } } return pixels_type; -- 2.20.1