Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2553339imu; Thu, 29 Nov 2018 06:48:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/U43S+DWa9pDo7pg4Hw3KokvGjnBJ43RPHT3xnSa+swGmaS5zufSUZQbON+MhW8vfw0RcnM X-Received: by 2002:a17:902:7791:: with SMTP id o17mr1735310pll.60.1543502917104; Thu, 29 Nov 2018 06:48:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543502917; cv=none; d=google.com; s=arc-20160816; b=xpswZGLw363rwnkXvsepkCy3tr6zuDXpPhem1g9LqwgEeIbJzyFYD4wvGu7xQH8AyE hNBWE5PFSKQICUH2FOl0iBLqVwVetyvbv4Iy9gKETAE8WxfHGq627F4O7lizmpDhBEZV CDAk9lApdrnkm5sPkr8FR9ptzsOZg1tRxGzJRLJMXIdHLgGIUwJ/XxHN5kCGaC001Mzl 7+yxz6McwoFeutdYLWneH7LWlwc2A9nGrlxrkh93036mAHkuFIdRiDfxPpDa0YLEmdFf ZYQLAHqYfj9v2dewtt73NTOWc1aUTN7dORSlcDvC9JUeAaG8CcrERP4F2vbmcovyk8Ty tVdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DTaQ66qfmySwUdwNSkL2fNNuCvFvuCxO/lUTIak8pbY=; b=WwMJYxpIujHuWYUBN8RvvzELaJLfRPPZpDygVb75RaEOur1CwJ8LvFxIUT8bc0LKft 3iOQJDNQaH6yAEZuXYmMsV2CcJyQsUEr5BhLQQktOMJ0oUZoscxhrqnipIG0Qs7BNuIX 1fuKZf4kyoszDlLyI9d2Hc8PWR3Xwwykxi1efu9kf6pVq4DTBYzk89BB4wMm4DGjYUXS r9LEf0VZmKBaJVkMB5y4VinlkQ0U4DCxmIubWBK60WAZYkinCFh/hdDFN0wu8DvmBjOo VESifVMANUz9RURIauRAXm7OL270iuiV6BYYIShoT/YvCBuSLGiVG+nDlQWbjOhrXm+1 1wAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gifOcTOM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a11si1974013pga.198.2018.11.29.06.48.21; Thu, 29 Nov 2018 06:48:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gifOcTOM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387503AbeK3BcY (ORCPT + 99 others); Thu, 29 Nov 2018 20:32:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:60524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731758AbeK3BcX (ORCPT ); Thu, 29 Nov 2018 20:32:23 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B5E75213A2; Thu, 29 Nov 2018 14:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501611; bh=EjyD5ItF790zzMwiw08SUObFOQxOi6FFODmYdi/mlPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gifOcTOMXu6a2JMZpaDC04McvFBjZ2G1BmRoV4iBvLT6MhS0PizT9uO9lT3udhV/c mdZDBpa33F/i1XE2n096Se5annM2YJ0S9pw/XeEw3LAn/nrsLGrjqBC16r0NroxwkU amUsKVEm2N8vDxj2YubgHssu5ILIjjVf/vw2XrsU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Junzhi Zhao , Philipp Zabel , CK Hu , David Airlie , Johan Hovold , Rob Herring , Sasha Levin Subject: [PATCH 4.14 068/100] drm/mediatek: fix OF sibling-node lookup Date: Thu, 29 Nov 2018 15:12:38 +0100 Message-Id: <20181129140104.781890622@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit ceff2f4dcd44abf35864d9a99f85ac619e89a01d ] Use the new of_get_compatible_child() helper to lookup the sibling instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (i.e. non-sibling) node. This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the parent device node). While at it, also fix the related cec-node reference leak. Fixes: 8f83f26891e1 ("drm/mediatek: Add HDMI support") Cc: stable # 4.8 Cc: Junzhi Zhao Cc: Philipp Zabel Cc: CK Hu Cc: David Airlie Signed-off-by: Johan Hovold Signed-off-by: Rob Herring Signed-off-by: Sasha Levin --- drivers/gpu/drm/mediatek/mtk_hdmi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index 690c67507cbc..aba27ea9cea5 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -1446,8 +1446,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, } /* The CEC module handles HDMI hotplug detection */ - cec_np = of_find_compatible_node(np->parent, NULL, - "mediatek,mt8173-cec"); + cec_np = of_get_compatible_child(np->parent, "mediatek,mt8173-cec"); if (!cec_np) { dev_err(dev, "Failed to find CEC node\n"); return -EINVAL; @@ -1457,8 +1456,10 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, if (!cec_pdev) { dev_err(hdmi->dev, "Waiting for CEC device %pOF\n", cec_np); + of_node_put(cec_np); return -EPROBE_DEFER; } + of_node_put(cec_np); hdmi->cec_dev = &cec_pdev->dev; /* -- 2.17.1