Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5642524imm; Mon, 27 Aug 2018 01:24:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaEVuBTvDnEMTZtN4C/bGHtbffQPXA0yljyLd2wMtprASbq2JkI+c/JlR+E35oNmxxrHmu4 X-Received: by 2002:a17:902:d213:: with SMTP id t19-v6mr12188549ply.63.1535358256168; Mon, 27 Aug 2018 01:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535358256; cv=none; d=google.com; s=arc-20160816; b=IJuF34Ho8ByupUwS0KL5L+b5kHGnBryI0L3n43D/RBE/CUzi7wbXmlFQLqV/FMm8T0 PPSU2eI//t4nr//kCRXB0zWaSkaDbW5spl33DnjBCgSIf6YkJFF9uKVejcbLKCVmge96 dqDpXGqVDos8CWuwmcrJcCF/v4D5mYmWpvhsxcyHRM6skn7c82EC+DBW05/EWJ1T2iIn iA0jWgTKOLJJ8Cif9uu2NGmvF6MQMbPGwWK3GkRqcrQvhKcdqh50R6O1mWgcvKTeylHk tWNvhFFIxuIv8eh7KZTVWXrApitRs1BiOww4pqIzTIShReyreM0bypQ3R7cuBKMuyRSc Nmbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=hy96WSGyk9n9yG0a0L2PRDsUVo4Lgg8GvUhoza4cHUU=; b=gnrMPDNXNBtbkEGmyhtTWPI3j4tZk9dvQFm/bhP+S0uCAbsyE3VKH8NcNAZsC19WrJ qOQSqy33IXlpuuHF4gpTdXVWX2tuXrMZmiiKZWW5xFwccbnod02KwlWsjVyOdLCS/J70 OsBZVpSvVbdCw93uPEiTq79G81LAe3pHS8qm4aYpe8jehT/6vo1EnNuiZOz0TWJ2jwXM 1io3Qfg9oyLtvuFBaMPKvk33Q85XjeEqS4EABdki8Xoh/DUn1v9kQjCKuw6r0/WfW0Jn P4Y0fllc/IMeuFWKTpST1CltRjHquXolDgLWrN/NdP6qoBk9EoQXI3E3vT6PphUyz9lR iF4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GM3Fo30k; 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 k2-v6si3530933pgp.602.2018.08.27.01.24.01; Mon, 27 Aug 2018 01:24:16 -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=GM3Fo30k; 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 S1727355AbeH0MIY (ORCPT + 99 others); Mon, 27 Aug 2018 08:08:24 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:37938 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727160AbeH0MIR (ORCPT ); Mon, 27 Aug 2018 08:08:17 -0400 Received: by mail-lj1-f196.google.com with SMTP id p6-v6so11638125ljc.5; Mon, 27 Aug 2018 01:22:39 -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; bh=hy96WSGyk9n9yG0a0L2PRDsUVo4Lgg8GvUhoza4cHUU=; b=GM3Fo30kH4SLrZpYq/eF9/G/Y+i/mWJ5BtOAi+jkEF0RJeFq0wgONQ32xGQU0+e8s6 ARFYDdsUnMkubB4eK30uiS9Y8flwP4avAWVHYG31ktPeHjRxvGIop/f2rH6Is9bQLoQi YtAXl5JVnzdU2+B/r330JDnAFrSvqZD7rRWA46q0iGWgNVad81AdlHXtuXgmv7N9FFJM ovjaJWuyb4LAoT2BS2gweCVj70oBORA4W4OrssE8mLaVlccc4aLZUmd3YuFeqHyUlyDT +cuMR2219+lkQ+fJ6Gl2CAp6mza1EhIUxAk0D4jgM/9HNJNRaJpfLdvL6wdN5ZulttDC otug== 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; bh=hy96WSGyk9n9yG0a0L2PRDsUVo4Lgg8GvUhoza4cHUU=; b=SbMt44OOjeJodkQ9qLzKbX8BQLqMjgTuby+WDSjDFrfGBXVFwb9b2AByR+dF2nSqAw uDz7UrX8EFRFjwVvBnmQ68nT3SFnX1A5IriKcfCCH/etEMun99yPm8IV+dTAD4F+7KQT O8nY5shWezhl0ontVoYclhsUvcrS++D2ji1B7bng2qNrJ+DTKSFrKH9S7yG75slMWFp6 p5JsY+5gT27KqbQR+jrVk3nnut/JYAut5vQ8TdN9CKNpIK4xrvcriVMh+UtUiqfJ1A1T JFGyTGmkac8AGWOCKYhoYkZAStknXgq5LImaRkod3M9UXlHEqy3TRi+1pSrA9RC6vLUq tHig== X-Gm-Message-State: APzg51Bje/M20ay6xaxWF41hvcoNYkONseTZyFb6DGWp+q+VP4AnXYJJ Ry5/PuVuskLy4sRbkNXn+UE= X-Received: by 2002:a2e:9791:: with SMTP id y17-v6mr7574283lji.41.1535358159114; Mon, 27 Aug 2018 01:22:39 -0700 (PDT) Received: from xi.terra ([85.230.190.116]) by smtp.gmail.com with ESMTPSA id o11-v6sm2768201lfl.1.2018.08.27.01.22.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 01:22:36 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1fuCn6-0005sO-GM; 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 , CK Hu , Philipp Zabel , Rob Clark , David Airlie , Ulf Hansson , Josh Wu , Boris Brezillon , Doug Berger , Florian Fainelli , "David S. Miller" , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Samuel Ortiz , Sebastian Reichel , Martin Blumenstingl Subject: [PATCH v2 0/9] of: fix compatible-child-node lookups Date: Mon, 27 Aug 2018 10:21:44 +0200 Message-Id: <20180827082153.22537-1-johan@kernel.org> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Several drivers currently use of_find_compatible_node() to lookup child nodes while failing to notice that the of_find_ functions search the entire tree depth-first (from a given start node) and therefore can match unrelated nodes. The fact that these functions also drop a reference to the node they start searching from (e.g. the parent node) is typically also overlooked, something which can lead to use-after-free bugs (e.g. after probe deferrals). This series adds a new helper, similar to of_get_child_by_name(), that can be used to lookup compatible child nodes, and uses the new helper to fix child-node lookups throughout the tree. This is related to the fixes I posted about a year ago, which addressed a similar anti-pattern when looking up child nodes by name. Since it took me more than a year to get all those fixes into Linus' tree (one fix is still pending), and as these fixes depend on the new helper, I'm suggesting that these all go in through Rob's or Greg's trees. Alternatively, the helper could go into to -rc2, and I'll be pinging submaintainers for the coming year as well. ;) Johan Changes in v2 - fix !CONFIG_OF build by adding missing inline keyword - amend commit messages and explicitly mention that the of_find functions search the entire tree from a given start node - add Sebastian's and Martin's Reviewed-by and Acked-by to patches 4/9 and 9/9 respectively - drop or fix a couple of CC addresses that bounced Johan Hovold (9): of: add helper to lookup compatible child node drm/mediatek: fix OF sibling-node lookup drm/msm: fix OF child-node lookup mmc: meson-mx-sdio: fix OF child-node lookup mtd: nand: atmel: fix OF child-node lookup net: bcmgenet: fix OF child-node lookup net: stmmac: dwmac-sun8i: fix OF child-node lookup NFC: nfcmrvl_uart: fix OF child-node lookup power: supply: twl4030-charger: fix OF sibling-node lookup drivers/gpu/drm/mediatek/mtk_hdmi.c | 5 ++-- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 5 ++-- drivers/mmc/host/meson-mx-sdio.c | 8 ++++-- drivers/mtd/nand/raw/atmel/nand-controller.c | 11 +++++--- drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 +- .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 12 +++++++-- drivers/nfc/nfcmrvl/uart.c | 5 ++-- drivers/of/base.c | 25 +++++++++++++++++++ drivers/power/supply/twl4030_charger.c | 5 ++-- include/linux/of.h | 8 ++++++ 10 files changed, 68 insertions(+), 18 deletions(-) -- 2.18.0