linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] clk: Do not register provider with a NULL dev->of_node
@ 2021-04-23 17:13 Tudor Ambarus
  2021-04-23 17:13 ` [PATCH 1/2] " Tudor Ambarus
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Tudor Ambarus @ 2021-04-23 17:13 UTC (permalink / raw)
  To: mturquette, sboyd, nsaenz, maxime, gregkh, rafael, khilman,
	ulf.hansson, len.brown, pavel, robh+dt, frowand.list, maz, tglx,
	saravanak, geert, nsaenzjulienne, linux, guillaume.tucker
  Cc: linux-clk, linux-kernel, corbet, nicolas.ferre, claudiu.beznea,
	linux-doc, linux-pm, devicetree, linux-acpi, kernel-team,
	linux-rpi-kernel, Tudor Ambarus

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


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

end of thread, other threads:[~2021-04-24  1:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 17:13 [PATCH 0/2] clk: Do not register provider with a NULL dev->of_node Tudor Ambarus
2021-04-23 17:13 ` [PATCH 1/2] " Tudor Ambarus
2021-04-23 17:24   ` Saravana Kannan
2021-04-23 18:21     ` nicolas saenz julienne
2021-04-23 18:35       ` Tudor.Ambarus
2021-04-23 17:13 ` [PATCH 2/2] clk: bcm: rpi: Do not call devm_of_clk_add_hw_provider " Tudor Ambarus
2021-04-23 19:12 ` [PATCH] clk: Skip clk provider registration when np is NULL Tudor Ambarus
2021-04-23 19:16   ` Tudor.Ambarus
2021-04-24  1:17   ` Stephen Boyd

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).