Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5643559imm; Mon, 27 Aug 2018 01:25:39 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbv1N0nugOjwg36rzhhE+cQwIlh0nc95lOrLGCGXN+MQlPbrQHTDuAKbKPK7B5g3eJvqg/o X-Received: by 2002:a62:9992:: with SMTP id t18-v6mr13182170pfk.239.1535358339192; Mon, 27 Aug 2018 01:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535358339; cv=none; d=google.com; s=arc-20160816; b=PcAX66lm+VoxVRuMuj5armki3/yIeeaamnJM2y3ZqNgSN8NNwpH9SqhLSKQPU/vsqh I8a/ykCjuileEBxAmym6WDgnqDFQZ1wfUgPpgn6oydY0imKbDS8niBrqxGUgJG69xKOl 639qabadzotWX9oUNU2s7mO2aqxA8nCl65NqY8s0IwQ7MsILX/DTRYfoYcCpVpltfIAJ GxqtIvu4fHzAducqOkzlYkhkRLIeI2mFt98A8qj3BpiP89u336ZzE1gDV1VoRCE8Mu1E t8e9K7N66wCIIfDJ0/vjJHTMOuHPknnI2LsMWWeZ7VdQ63ZEPoH3v2BphuqZPSblWJl0 qFGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=kMK7vADaYUb3uoA3K0PRlMXBDFYMW3OHjrli6EBxJE4=; b=vNaOtKFWywOq8Aoq7zYhvC15Q6cCibFu43BDQaXtoJtEsEWsbUgabSlqb49gie02iP xBqPTG8B8HDWTIBs5b01LhSH2pH1Aye2dcmE2vA7vmm5/VCI+/w3vfnbVMqM0qM/6Pwi JIOb35AQ2nG/2Nu2V4NFhZRDDed0kQvD3PaKpZYqRjdCL+ZHrqSQ4PZ1pn9shs184ipa zMyRL25XnRI8i31GMNqdcm06g4QPy4xmE9wZFGEEL2KHmBrgX8SiNQdX663snJ0QsEeT En/88Td79AH3ym2r5Lz/BZYTu4HSAccgWeyTdL8mgjYxILPckNrWOEdwB2adFZcvPyPp esOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=MCKdtezP; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9-v6si13649403pls.132.2018.08.27.01.25.24; Mon, 27 Aug 2018 01:25:39 -0700 (PDT) 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=fail header.i=@gmail.com header.s=20161025 header.b=MCKdtezP; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727390AbeH0MIx (ORCPT + 99 others); Mon, 27 Aug 2018 08:08:53 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:33963 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbeH0MIM (ORCPT ); Mon, 27 Aug 2018 08:08:12 -0400 Received: by mail-lj1-f193.google.com with SMTP id f8-v6so11644545ljk.1; Mon, 27 Aug 2018 01:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=kMK7vADaYUb3uoA3K0PRlMXBDFYMW3OHjrli6EBxJE4=; b=MCKdtezPpLuUtsbonrbkCwRNnI36hXL3H/YNYt4As9iRpmwfGduA/SlRk1jQQrZrWv pULvUc4Cs1eU4GVqpqlfca4zhHIdADoeXsX+CyaN2r+53/d9Q+4wCzngPZZyic0gOoAF 8T7iz1NyM1ee+TsGBcx3/g6NCg3BARZshQ9sUCLRwnJJ+OHXddWp7BjQB/sz9QTAsgdL FVfFxVYMyTEaqSWheTeEuR/3iCxprEFiRBive9ytOJBGCR/yZsWoEkt+isRRgAenNq7g 2PYlC2XaCoupiFA07VAmGUQpwkqaCOX1H62kGy+J2Kua75V3kbKdLhCAhAyLdZHu15W2 e/VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=kMK7vADaYUb3uoA3K0PRlMXBDFYMW3OHjrli6EBxJE4=; b=Y8lS7PRTkRNaEoNTVAXTumoYH6tbn2NlmZhiSBnWewBOE3YSWUz/HZGbpfG0pae0Z6 l4E/QYd1SnyR+kOZ4VkuJ1JgTN4mkS6eH3mlQVjKOIayA5qDaj7K0L+poqd2E3cZZWsX wXHVHVFyVznHeBihTIrF3BLIW/hyK7cV0JLfRUNo/meGPHihFXsprY/rY80fzmPCjhXj gM3UO0+1hhPEhYDk3bEAvzYkjLRMW9qSsmEZBTHH51Xi9ytbOpNDnnkQXRIRKKNnqj5w nDImCwblPoG+xHOSdoIHMyTovCPFzNVMakIRmq341GCgyk4+rf2oLHfcBsP+XgO4G04i YomQ== X-Gm-Message-State: APzg51Ch2HnD0Bo7/l+9L07cAiM/SZCJcJcsp84UHGO3Xmkt7fGvpWoY sirYeyG3Y80K00onYbFRTyc= X-Received: by 2002:a2e:1290:: with SMTP id 16-v6mr8186756ljs.94.1535358154357; Mon, 27 Aug 2018 01:22:34 -0700 (PDT) Received: from xi.terra ([85.230.190.116]) by smtp.gmail.com with ESMTPSA id u2-v6sm2642547ljg.55.2018.08.27.01.22.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 01:22:31 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1fuCn6-0005sc-PS; Mon, 27 Aug 2018 10:22:28 +0200 From: Johan Hovold To: Rob Herring , Greg Kroah-Hartman Cc: Frank Rowand , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable , Jordan Crouse , Rob Clark , David Airlie Subject: [PATCH v2 3/9] drm/msm: fix OF child-node lookup Date: Mon, 27 Aug 2018 10:21:47 +0200 Message-Id: <20180827082153.22537-4-johan@kernel.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827082153.22537-1-johan@kernel.org> References: <20180827082153.22537-1-johan@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; } -- 2.18.0