]> git.baikalelectronics.ru Git - kernel.git/commit
clk: Skip clk provider registration when np is NULL
authorTudor Ambarus <tudor.ambarus@microchip.com>
Mon, 26 Apr 2021 06:56:18 +0000 (09:56 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 May 2021 06:47:25 +0000 (08:47 +0200)
commit3989d77b320cd94ccd5b9b5adc47671f74420787
treead3ccecf1f1d1e69260333ce26aa328c12ce8ed1
parent6be3c5fc8846f7f06fb5eebc212e2040f41f7b4e
clk: Skip clk provider registration when np is NULL

commit 503055b76f70 ("clk: Mark fwnodes when their clock provider is added")
revealed that clk/bcm/clk-raspberrypi.c driver calls
devm_of_clk_add_hw_provider(), with a NULL dev->of_node, which resulted in a
NULL pointer dereference in of_clk_add_hw_provider() when calling
fwnode_dev_initialized().

Returning 0 is reducing the if conditions in driver code and is being
consistent with the CONFIG_OF=n inline stub that returns 0 when CONFIG_OF
is disabled. The downside is that drivers will maybe register clkdev lookups
when they don't need to and waste some memory.

Fixes: 503055b76f70 ("clk: Mark fwnodes when their clock provider is added")
Fixes: 2f31ca6bf6ce ("clk: Mark fwnodes when their clock provider is added/removed")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Reviewed-by: Saravana Kannan <saravanak@google.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20210426065618.588144-1-tudor.ambarus@microchip.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/clk/clk.c