linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tudor Ambarus <tudor.ambarus@microchip.com>
To: <mturquette@baylibre.com>, <sboyd@kernel.org>,
	<nsaenz@kernel.org>, <maxime@cerno.tech>,
	<gregkh@linuxfoundation.org>, <rafael@kernel.org>,
	<khilman@kernel.org>, <ulf.hansson@linaro.org>,
	<len.brown@intel.com>, <pavel@ucw.cz>, <robh+dt@kernel.org>,
	<frowand.list@gmail.com>, <maz@kernel.org>, <tglx@linutronix.de>,
	<saravanak@google.com>, <geert@linux-m68k.org>,
	<nsaenzjulienne@suse.de>, <linux@roeck-us.net>,
	<guillaume.tucker@collabora.com>
Cc: <linux-clk@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<corbet@lwn.net>, <nicolas.ferre@microchip.com>,
	<claudiu.beznea@microchip.com>, <linux-doc@vger.kernel.org>,
	<linux-pm@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-acpi@vger.kernel.org>, <kernel-team@android.com>,
	<linux-rpi-kernel@lists.infradead.org>,
	Tudor Ambarus <tudor.ambarus@microchip.com>
Subject: [PATCH 0/2] clk: Do not register provider with a NULL dev->of_node
Date: Fri, 23 Apr 2021 20:13:32 +0300	[thread overview]
Message-ID: <20210423171335.262316-1-tudor.ambarus@microchip.com> (raw)

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


             reply	other threads:[~2021-04-23 17:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 17:13 Tudor Ambarus [this message]
2021-04-23 17:13 ` [PATCH 1/2] clk: Do not register provider with a NULL dev->of_node 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210423171335.262316-1-tudor.ambarus@microchip.com \
    --to=tudor.ambarus@microchip.com \
    --cc=claudiu.beznea@microchip.com \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=guillaume.tucker@collabora.com \
    --cc=kernel-team@android.com \
    --cc=khilman@kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux@roeck-us.net \
    --cc=maxime@cerno.tech \
    --cc=maz@kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=nsaenz@kernel.org \
    --cc=nsaenzjulienne@suse.de \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=saravanak@google.com \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).