mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sander Speetjens <sander.speetjens@gmail.com>
To: Florian Fainelli <florian.fainelli@broadcom.com>,
	 Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	 Eric Anholt <eric@anholt.net>, Stefan Wahren <wahrenst@gmx.net>,
	 Stephen Boyd <sboyd@kernel.org>,
	Nicolas Saenz Julienne <nsaenz@kernel.org>
Cc: linux-rpi-kernel@lists.infradead.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,  sander.speetjens@gmail.com
Subject: [PATCH 6/6] firmware: raspberrypi: Handle device registration errors
Date: Sat, 07 Nov 2026 17:38:10 +0100	[thread overview]
Message-ID: <20261107-fix-raspberrypi-firmware-v1-6-707362c710cd@gmail.com> (raw)
In-Reply-To: <20261107-fix-raspberrypi-firmware-v1-0-707362c710cd@gmail.com>

Check the return value of platform_device_register_data() before assigning
it to the global rpi_hwmon / rpi_clk pointers.  Previously an ERR_PTR was
stored on failure, which could be used later without proper checking.

Do not propagate the error to the caller.  The hwmon and clock platform
devices are optional helpers; making the whole rpi_firmware_probe() fail
just because a child platform device could not be created would be worse,
as it would lose the firmware interface that many other drivers need.

Fixes: 70eea1bbb556 ("firmware: raspberrypi: Register hwmon driver")
Fixes: 91f2cf4a6b21 ("firmware: raspberrypi: register clk device")
Signed-off-by: Sander Speetjens <sander.speetjens@gmail.com>
---
 drivers/firmware/raspberrypi.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index 57f21e4e65d6..48cb8063ddb9 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -203,6 +203,7 @@ rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
 static void
 rpi_register_hwmon_driver(struct device *dev, struct rpi_firmware *fw)
 {
+	struct platform_device *pdev;
 	u32 packet;
 	int ret = rpi_firmware_property(fw, RPI_FIRMWARE_GET_THROTTLED,
 					&packet, sizeof(packet));
@@ -210,13 +211,19 @@ rpi_register_hwmon_driver(struct device *dev, struct rpi_firmware *fw)
 	if (ret)
 		return;
 
-	rpi_hwmon = platform_device_register_data(dev, "raspberrypi-hwmon",
-						  -1, NULL, 0);
+	pdev = platform_device_register_data(dev, "raspberrypi-hwmon",
+					     -1, NULL, 0);
+
+	if (IS_ERR(pdev))
+		return;
+
+	rpi_hwmon = pdev;
 }
 
 static void rpi_register_clk_driver(struct device *dev)
 {
 	struct device_node *firmware;
+	struct platform_device *pdev;
 
 	/*
 	 * Earlier DTs don't have a node for the firmware clocks but
@@ -230,8 +237,13 @@ static void rpi_register_clk_driver(struct device *dev)
 		return;
 	}
 
-	rpi_clk = platform_device_register_data(dev, "raspberrypi-clk",
-						-1, NULL, 0);
+	pdev = platform_device_register_data(dev, "raspberrypi-clk",
+					     -1, NULL, 0);
+
+	if (IS_ERR(pdev))
+		return;
+
+	rpi_clk = pdev;
 }
 
 static void rpi_register_rtc_driver(struct device *dev)

-- 
2.56.0


      parent reply	other threads:[~2026-11-07 16:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07 16:38 [PATCH 0/6] firmware: raspberrypi: Style cleanups and registration error handling Sander Speetjens
2026-11-07 16:38 ` [PATCH 1/6] firmware: raspberrypi: Add blank line after declaration in response_callback Sander Speetjens
2026-11-07 16:38 ` [PATCH 2/6] firmware: raspberrypi: Fix indentation of return statement Sander Speetjens
2026-11-07 16:38 ` [PATCH 3/6] firmware: raspberrypi: Add blank line after declaration in probe error path Sander Speetjens
2026-11-07 16:38 ` [PATCH 4/6] firmware: raspberrypi: Remove unnecessary braces in transaction helper Sander Speetjens
2026-11-07 16:38 ` [PATCH 5/6] firmware: raspberrypi: Document memory barriers in property list path Sander Speetjens
2026-11-07 16:38 ` Sander Speetjens [this message]

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=20261107-fix-raspberrypi-firmware-v1-6-707362c710cd@gmail.com \
    --to=sander.speetjens@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=eric@anholt.net \
    --cc=florian.fainelli@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=nsaenz@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=wahrenst@gmx.net \
    /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

all inboxes | Powered by JetHome®