Skip to content

clk: Do not register provider with a NULL dev->of_node

Tudor Ambarus linux-acpi linux-clk linux-devicetree linux-doc linux-pm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2clk: Do not register provider with a NULL dev->of_nodedrivers/clk/clk.c+7 -53 replies
2/2clk: bcm: rpi: Do not call devm_of_clk_add_hw_provider with a NULL dev->of_nodedrivers/clk/bcm/clk-raspberrypi.c+6 -40 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchStephen Boyd
SeriesR-b
1/2
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] clk: Do not register provider with a NULL dev->of_node

This fixes a NULL pointer dereference that was revealed by commit 6579c8d97ad7 ("clk: Mark fwnodes when their clock provider is added")

I chose to just return -ENODEV when a driver calls devm_of_clk_add_hw_provider() with a NULL dev->of_node, because it seems natural to return a failure when one asks for an _of_ function to do something, but by providing with a NULL of_node. Plus, it avoids some waste of memory, as the call to devres_alloc() will not take place.

The opinions on how to handle this NULL pointer dereference were split, either by returning an error when one calls devm_of_clk_add_hw_provider() with a NULL dev->of_node, as I did, or by
return 0 in of_clk_add_hw_provider() when np == NULL and
return 0 in of_clk_del_provider() when np == NULL.
Let me know if you prefer the second approach.

Compile tested only.

Tudor Ambarus (2):
clk: Do not register provider with a NULL dev->of_node
clk: bcm: rpi: Do not call devm_of_clk_add_hw_provider with a NULL

    dev->of_node
 drivers/clk/bcm/clk-raspberrypi.c | 10 ++++++----
 drivers/clk/clk.c                 | 12 +++++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)
Signature · 1 line
2.25.1