From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f196.google.com ([209.85.210.196]:42303 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729107AbeK1CTC (ORCPT ); Tue, 27 Nov 2018 21:19:02 -0500 Received: by mail-pf1-f196.google.com with SMTP id 64so8518895pfr.9 for ; Tue, 27 Nov 2018 07:20:48 -0800 (PST) Date: Tue, 27 Nov 2018 07:19:38 -0800 From: Johan Hovold To: gregkh@linuxfoundation.org Cc: johan@kernel.org, airlied@linux.ie, jcrouse@codeaurora.org, robdclark@gmail.com, robh@kernel.org, stable@vger.kernel.org Subject: Re: FAILED: patch "[PATCH] drm/msm: fix OF child-node lookup" failed to apply to 4.14-stable tree Message-ID: <20181127151938.GS2403@localhost> References: <154263645736118@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <154263645736118@kroah.com> Sender: stable-owner@vger.kernel.org List-ID: On Mon, Nov 19, 2018 at 03:07:37PM +0100, Greg Kroah-Hartman wrote: > > The patch below does not apply to the 4.14-stable tree. > If someone wants it applied there, or to any other stable or longterm > tree, then please email the backport, including the original git commit > id to . This one also depends on 36156f9241cb ("of: add helper to lookup compatible child node") Johan > ------------------ original commit in Linus's tree ------------------ > > From f9a7082327e26f54067a49cac2316d31e0cc8ba7 Mon Sep 17 00:00:00 2001 > From: Johan Hovold > Date: Mon, 27 Aug 2018 10:21:47 +0200 > Subject: [PATCH] drm/msm: fix OF child-node lookup > > Use the new of_get_compatible_child() helper to lookup the legacy > pwrlevels child node 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-child) 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 probed device's node). > > While at it, also fix the related child-node reference leak. > > Fixes: e2af8b6b0ca1 ("drm/msm: gpu: Use OPP tables if we can") > Cc: stable # 4.12 > Cc: Jordan Crouse > Cc: Rob Clark > Cc: David Airlie > Signed-off-by: Johan Hovold > Signed-off-by: Rob Herring > > diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c > index da1363a0c54d..93d70f4a2154 100644 > --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c > +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c > @@ -633,8 +633,7 @@ static int adreno_get_legacy_pwrlevels(struct device *dev) > struct device_node *child, *node; > int ret; > > - node = of_find_compatible_node(dev->of_node, NULL, > - "qcom,gpu-pwrlevels"); > + node = of_get_compatible_child(dev->of_node, "qcom,gpu-pwrlevels"); > if (!node) { > dev_err(dev, "Could not find the GPU powerlevels\n"); > return -ENXIO; > @@ -655,6 +654,8 @@ static int adreno_get_legacy_pwrlevels(struct device *dev) > dev_pm_opp_add(dev, val, 0); > } > > + of_node_put(node); > + > return 0; > } > >