Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10784456imu; Thu, 6 Dec 2018 06:47:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/X0W6epYSAwkStQbTqCX3yU4oiA6aJgfNUD+0LRetjkOWAPG35qUS0oowdyO2Gu78/EplI8 X-Received: by 2002:a63:902:: with SMTP id 2mr22739962pgj.219.1544107622930; Thu, 06 Dec 2018 06:47:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544107622; cv=none; d=google.com; s=arc-20160816; b=HcMMCj96mWBkE0UjBXE5vJx4QQ1/OZj/hpazeIGWwX0boq5yBPjUunU35LiQi29KxN EIFT5IROYSi0M0Ug7/IYRIJBm9ru82aJjkPfk/UWL4XtyG4iazwrwNn1sJhXIT4aKO/k EY0mTB7VZZdRV35DdptZCFrVRr+EBvQ4a/KMkJ7mb2QcUHy+/J5JguW7xEjNMhM2OAY9 4EYrl6ACfqP3YeZLwxYT9O9D7uYJpNzuIjoJweHuC36ZFgPrjiKIiqeWWc2xJx12A36t jBZkEUIWQKci0qTE0ZFaouhM6W0TAyEOoFFYEJ46CW37eNBguvq9wUZzb2y0GKPLxSnx 7i4A== 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=+GzCqGZMDjEX0yeXFLUEQZ6JiQPSUsx2QN1MMsOPU74=; b=gKBidZAcI2RP5DFdw6OJRo4CuqhciqlrGpfADJgZc9YtFZa/E629MvGbL0Rtokr8gE II+dCanv10WjiANE3E+15GZWb0pcdPwuTfQ41AxGYYIAwZwIjdf3UvI8iwCrY/aElrzP vcQ/0rO6sURVoKG4WalroJwTV0jlFLwXxZAZMry0OmGw3qqEbkkEPdSRjLuwjfIMXTtM vqBMJvYRzr2xh1USAfheTEiO8RV6xu6UPv3bIkgNiBdlckI/8Gok+UP3wfk9oF59Jd+k z+M/+HowegPQcp5evAOhhrnuCTheJ9Kj2ML+BNdRiTTB83sDKW9enMaUuB9zVJgTSNmd wbZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G4KdiwM8; 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 l24si401026pgj.171.2018.12.06.06.46.47; Thu, 06 Dec 2018 06:47:02 -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=G4KdiwM8; 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 S1730974AbeLFOpA (ORCPT + 99 others); Thu, 6 Dec 2018 09:45:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:49640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730936AbeLFOoz (ORCPT ); Thu, 6 Dec 2018 09:44:55 -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 6237B2146D; Thu, 6 Dec 2018 14:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107494; bh=IkkIa/sGM/RivtydZKYehC3FabozOrIPbzK5Hmuggwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G4KdiwM8KCcCipcm1NJozx6vuA84s/oXiD3g4uCVlshTS4fzRmL4xXkqPd8fFdAox SgoLmQrSFw9TlFio08u4qs8d96ZHdHFLsN4no53x96Y7IjsPfDJQx0z9ULNj/rzrr6 ZWX9yWO0EoUjg/KpOYuw1uT+MLA33kljRlDQ0nmM= 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.9 027/101] drm/mediatek: fix OF sibling-node lookup Date: Thu, 6 Dec 2018 15:38:26 +0100 Message-Id: <20181206143013.137783137@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143011.174892052@linuxfoundation.org> References: <20181206143011.174892052@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.9-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 [ johan: backport to 4.9 ] Signed-off-by: Johan Hovold 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 %s\n", cec_np->full_name); + of_node_put(cec_np); return -EPROBE_DEFER; } + of_node_put(cec_np); hdmi->cec_dev = &cec_pdev->dev; /*