Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3471314imu; Sun, 11 Nov 2018 15:52:28 -0800 (PST) X-Google-Smtp-Source: AJdET5fyLTXH3znyMWIWhmEkzlh5wtM7JHXxiVQCekF+HCxZ+vhyuGH33urk32xZoO5RDciLtjrw X-Received: by 2002:a63:6205:: with SMTP id w5mr15404461pgb.53.1541980348395; Sun, 11 Nov 2018 15:52:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980348; cv=none; d=google.com; s=arc-20160816; b=KNEpWPIvHg1u5dhI+ugVOROv0klwwl5YvNnWOrW3OCpyD72zOY/T6Hc8wNnVLGZ3go +FsGSt2l7bly2vjlLl3QML4ZKnV5j8ifApGln12C+sIxUi4ynGvK949HV5y+8QLjDvPA LEPBKFnQ1ntJuCpx62esudOxOvkLUYTOE5cubBdKvf57sJcYn/jEph3pJ1MHIztR5I7Q UwnY2yZgUyORXTdlyOKKpG+9ziS6xRKwbhQy6NO8F9OU4vnTzX1i5NfiPWVcqF2fI4XT cxwBVyOf9MdKC9AdgjymCp1e/qSbZrocGv/aCplgT3Sie80ALJvuyJ6lOoeZPKqgH/Oj UMzQ== 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=BRrK/hpZcpl+CTKZxBEMSs76aDFk0f7a3Shcq1nuT7g=; b=bI9Uy3vLQ8vCzaju0gifuhKFvkiN9bFUX4ps1YvrLxKTQVX7LTHkZI51bc3dmjd8MZ vR5eDLt2yn+x3IRcpUpFTGlH6xFlDxtvJRWQfFX2nv7SLWdKUDxrFJAQeQcdUoWHOmiQ w11dtoPZnma+aVThSn/mOI0USGh24/bQJSogVClEV92GvHC9UVtjDNolTRci/kFxNFwY TldoYr3Q6s7h0WtspItptwd8BYODW5gQC+q8oIDrk+CLLOeFkZqOwUMxcpoDeVBoFraP m/uSIYlPtMxe6YkilSLFEF4U4UAYB7loz3svnwgrOAY2MN+bzAiYIdFzmc2WJPVEuWh6 l1VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dmQOr3gr; 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 f15-v6si9254441pff.131.2018.11.11.15.52.13; Sun, 11 Nov 2018 15:52:28 -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=dmQOr3gr; 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 S1733043AbeKLJlE (ORCPT + 99 others); Mon, 12 Nov 2018 04:41:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:37518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732921AbeKLISe (ORCPT ); Mon, 12 Nov 2018 03:18:34 -0500 Received: from localhost (unknown [206.108.79.134]) (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 21F1F22353; Sun, 11 Nov 2018 22:28:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975319; bh=L9GzWmHNS4bR6jqgGCuty8pd4HM8TpRHdLqxd2N/uN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dmQOr3graMktBSZsu2iWoGlqfnHf6WVnPH9VlfbArVrTqQuu8qoSJGFWvjRkfx7sb t9KbGHcy8iNgghgKSAxsD6vK5lrWDR4iDJjDSX8fO7TIusObdsqsN4lXPSiaOLqpuT +hGpNCY6TvThwqDz16BAe9vjAngBdbjILr0F35us= 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 Subject: [PATCH 4.19 312/361] drm/mediatek: fix OF sibling-node lookup Date: Sun, 11 Nov 2018 14:20:59 -0800 Message-Id: <20181111221658.365211527@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit ceff2f4dcd44abf35864d9a99f85ac619e89a01d upstream. 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: Greg Kroah-Hartman --- drivers/gpu/drm/mediatek/mtk_hdmi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- 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(struc } /* 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(struc 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; /*