linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/9] of: fix compatible-child-node lookups
@ 2018-08-27  8:21 Johan Hovold
  2018-08-27  8:21 ` [PATCH v2 1/9] of: add helper to lookup compatible child node Johan Hovold
                   ` (9 more replies)
  0 siblings, 10 replies; 32+ messages in thread
From: Johan Hovold @ 2018-08-27  8:21 UTC (permalink / raw)
  To: Rob Herring, Greg Kroah-Hartman
  Cc: Frank Rowand, devicetree, linux-kernel, 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

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2018-11-18 10:45 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-27  8:21 [PATCH v2 0/9] of: fix compatible-child-node lookups Johan Hovold
2018-08-27  8:21 ` [PATCH v2 1/9] of: add helper to lookup compatible child node Johan Hovold
2018-08-30 15:51   ` Rob Herring
2018-08-27  8:21 ` [PATCH v2 2/9] drm/mediatek: fix OF sibling-node lookup Johan Hovold
2018-08-27  8:21 ` [PATCH v2 3/9] drm/msm: fix OF child-node lookup Johan Hovold
2018-08-27  8:21 ` [PATCH v2 4/9] mmc: meson-mx-sdio: " Johan Hovold
2018-08-27 14:44   ` Ulf Hansson
2018-09-04 12:54     ` Johan Hovold
2018-09-05  6:30       ` Ulf Hansson
2018-08-27  8:21 ` [PATCH v2 5/9] mtd: nand: atmel: " Johan Hovold
2018-08-27  8:28   ` Boris Brezillon
2018-08-27  8:44     ` Johan Hovold
2018-08-27  8:48       ` Boris Brezillon
2018-08-27  9:44         ` Johan Hovold
2018-10-23 18:28           ` Rob Herring
2018-10-23 18:51             ` Boris Brezillon
2018-11-15 14:26               ` Johan Hovold
2018-11-18 10:45                 ` Boris Brezillon
2018-08-27  8:21 ` [PATCH v2 6/9] net: bcmgenet: " Johan Hovold
2018-08-31  0:47   ` Florian Fainelli
2018-09-04 12:56     ` Johan Hovold
2018-08-27  8:21 ` [PATCH v2 7/9] net: stmmac: dwmac-sun8i: " Johan Hovold
2018-08-28  8:06   ` Corentin Labbe
2018-08-29  7:54     ` Johan Hovold
2018-09-06 20:03   ` Corentin Labbe
2018-09-07  7:48     ` Johan Hovold
2018-08-27  8:21 ` [PATCH v2 8/9] NFC: nfcmrvl_uart: " Johan Hovold
2018-08-27  8:21 ` [PATCH v2 9/9] power: supply: twl4030-charger: fix OF sibling-node lookup Johan Hovold
2018-09-04 13:05 ` [PATCH v2 0/9] of: fix compatible-child-node lookups Johan Hovold
2018-10-23  9:19   ` Johan Hovold
2018-10-23 18:32     ` Rob Herring
2018-10-24  7:32       ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).