[PATCH 0/2] clk: Do not register provider with a NULL dev->of_node
From: Tudor Ambarus
Date: Fri Apr 23 2021 - 13:13:51 EST
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(-)
--
2.25.1