[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210423171335.262316-1-tudor.ambarus@microchip.com>
Date: Fri, 23 Apr 2021 20:13:32 +0300
From: Tudor Ambarus <tudor.ambarus@...rochip.com>
To: <mturquette@...libre.com>, <sboyd@...nel.org>, <nsaenz@...nel.org>,
<maxime@...no.tech>, <gregkh@...uxfoundation.org>,
<rafael@...nel.org>, <khilman@...nel.org>,
<ulf.hansson@...aro.org>, <len.brown@...el.com>, <pavel@....cz>,
<robh+dt@...nel.org>, <frowand.list@...il.com>, <maz@...nel.org>,
<tglx@...utronix.de>, <saravanak@...gle.com>,
<geert@...ux-m68k.org>, <nsaenzjulienne@...e.de>,
<linux@...ck-us.net>, <guillaume.tucker@...labora.com>
CC: <linux-clk@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<corbet@....net>, <nicolas.ferre@...rochip.com>,
<claudiu.beznea@...rochip.com>, <linux-doc@...r.kernel.org>,
<linux-pm@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-acpi@...r.kernel.org>, <kernel-team@...roid.com>,
<linux-rpi-kernel@...ts.infradead.org>,
Tudor Ambarus <tudor.ambarus@...rochip.com>
Subject: [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(-)
--
2.25.1
Powered by blists - more mailing lists