Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2958482imu; Mon, 19 Nov 2018 08:37:42 -0800 (PST) X-Google-Smtp-Source: AJdET5d0+rMlbY7rU/T2lPTrN03PoAOXgEK1vkd61qHY9BjeQbRPxejw7mPGDmYg6C4EwPxX2X72 X-Received: by 2002:a17:902:824:: with SMTP id 33-v6mr23560241plk.107.1542645462001; Mon, 19 Nov 2018 08:37:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542645461; cv=none; d=google.com; s=arc-20160816; b=ZyBDE4cjEjN9TspktKa9ftKTniB0s3kJsN2jFRrXTEX/pGRSS1g1C6Xbw2AOD3k2KI 4obMTnj7rbDur2GpaJFTh572lh6nLWP3bIszfopqsg2iL6pUqi8kuStMgCI2q8qbqyQ7 Y9jbXF2XwhbeSaRSYF6kRTvmMFmo8klui91qVExE7Ba5P/qL+l125CUa2Ky/ItNX2Vrn vt1xePyMjstAG/w1NFaG11EJqxVkyEFV2H6ocVbyleCKGOzhY88XDxItqwL4IEI2OjNQ kYxjvPIU4QUiVQtOGQpOCCvkHCooMOJgyyK3/u5UJydJeK4PzXOW22414GGWWolp7JtR vGcA== 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=Bl8e85xFgvYwPbeVNfxWoEsqCW1iZCDSrfL22BI4yRo=; b=qSAGvbiMZKLTfscOdWWr+kLv84IdljWr7hWR/eQLKsQB3C1D1MSU2dGxOgbmJ8SeLg 0vl+G6fT0QnbQpaGSwKsBL1dpeLYVwrpnKQyw86XM4Phi1CT5Urv678Pqyl0ZWdtoLKy Iqr7lJZuekLX+uJarBiY5tjFSqYgrzyRzT1geaRhYpbioxMe0XSiGdj7Km0UNZYVxdco I2s9BDHszkht43jnTqL7AEgd0cxcgRawo/3x9xVaaW+56HKMu4vN/QFOmk7r+g+Ztzjj iZdFYbcAWSLKaJyCtDh1iaHmipOvUWc/sYH5RzdXebrooy9XEsiY8qKbPtOTd1nhbHvZ N0rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BE42TFpL; 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 n13si34143112pgp.307.2018.11.19.08.37.26; Mon, 19 Nov 2018 08:37:41 -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=BE42TFpL; 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 S1731466AbeKTC6w (ORCPT + 99 others); Mon, 19 Nov 2018 21:58:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:58008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730381AbeKTC6v (ORCPT ); Mon, 19 Nov 2018 21:58:51 -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 584B12086A; Mon, 19 Nov 2018 16:34:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645283; bh=/c1Hk+oWdNJuifLRlgWmy6XC9pnW7Xe9Y2gQWYtwXSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BE42TFpLs5QxCyetC4jQI7CKKpeQbizLL3fN9O8p85A7x/eB5+r5c6xezLjEFFuXj sFdZVFBebnlCzMeGbW6PAA8KNB+BBR2bW489svr6uVd/UqhTH37bu54N/DF3zH1pbv vYALM7Ke0siPjinM/dedz+kc38v7WF4s1GD2PQZo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jordan Crouse , Rob Clark , David Airlie , Johan Hovold , Rob Herring Subject: [PATCH 4.19 068/205] drm/msm: fix OF child-node lookup Date: Mon, 19 Nov 2018 17:26:15 +0100 Message-Id: <20181119162629.210195640@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@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 f9a7082327e26f54067a49cac2316d31e0cc8ba7 upstream. 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 Signed-off-by: Greg Kroah-Hartman 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; }