Skip to content

of: fix compatible-child-node lookups

Johan Hovold linux-devicetree lkml stable 2 versions – Applied

Status from this message: I've applied this one and plan to send to Linus tomorrow.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest9 patches 22 repliesApplied
  2. v19 patches 8 repliesSuperseded

Changes in v2 from the cover letter

- 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

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/9of: add helper to lookup compatible child nodedrivers/of/base.c include/linux/of.h+33 -01 reply
2/9drm/mediatek: fix OF sibling-node lookupdrivers/gpu/drm/mediatek/mtk_hdmi.c+3 -20 replies
3/9drm/msm: fix OF child-node lookupdrivers/gpu/drm/msm/adreno/adreno_gpu.c+3 -20 replies
4/9mmc: meson-mx-sdio: fix OF child-node lookupdrivers/mmc/host/meson-mx-sdio.c+6 -23 replies
5/9mtd: nand: atmel: fix OF child-node lookupdrivers/mtd/nand/raw/atmel/nand-controller.c+7 -48 replies
6/9net: bcmgenet: fix OF child-node lookupdrivers/net/ethernet/broadcom/genet/bcmmii.c+1 -12 replies
7/9net: stmmac: dwmac-sun8i: fix OF child-node lookupdrivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c+10 -24 replies
8/9NFC: nfcmrvl_uart: fix OF child-node lookupdrivers/nfc/nfcmrvl/uart.c+2 -30 replies
9/9power: supply: twl4030-charger: fix OF sibling-node lookupdrivers/power/supply/twl4030_charger.c+3 -20 replies

Reviews trailers per patch

4 of 9 patches have a Reviewed-by or Acked-by.

PatchMartin BlumenstinglSebastian ReichelBoris BrezillonUlf HanssonFlorian FainelliCorentin Labbe
1/9
2/9
3/9
4/9A-b A-b
5/9A-b
6/9R-b
7/9T-b
8/9
9/9R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/9] of: fix compatible-child-node lookups

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(-)
Signature · 1 line
2.18.0