From: Song Guo <songguo@google.com>
To: Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Cc: Song Guo <songguo@google.com>
Subject: [PATCH v2 1/3] misc: open-dice: do not assume dev->of_node is valid
Date: Wed, 15 Jul 2026 12:21:44 +0000 [thread overview]
Message-ID: <20260715122146.4069884-2-songguo@google.com> (raw)
In-Reply-To: <20260715122146.4069884-1-songguo@google.com>
dev->of_node is not null only when the device is configured via device
tree. When the matching device is configured by other means (like ACPI),
the current code will cause null pointer dereference.
Signed-off-by: Song Guo <songguo@google.com>
---
drivers/misc/open-dice.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/open-dice.c b/drivers/misc/open-dice.c
index 45060fb4ea27..094b24dfc6ea 100644
--- a/drivers/misc/open-dice.c
+++ b/drivers/misc/open-dice.c
@@ -118,13 +118,18 @@ static int __init open_dice_probe(struct platform_device *pdev)
{
static unsigned int dev_idx;
struct device *dev = &pdev->dev;
- struct reserved_mem *rmem;
+ struct reserved_mem *rmem = NULL;
struct open_dice_drvdata *drvdata;
int ret;
- rmem = of_reserved_mem_lookup(dev->of_node);
- if (!rmem) {
- dev_err(dev, "failed to lookup reserved memory\n");
+ if (dev->of_node) {
+ rmem = of_reserved_mem_lookup(dev->of_node);
+ if (!rmem) {
+ dev_err(dev, "failed to lookup reserved memory\n");
+ return -EINVAL;
+ }
+ } else {
+ dev_err(dev, "device not supported (no DT node)\n");
return -EINVAL;
}
--
2.55.0.141.g00534a21ce-goog
next prev parent reply other threads:[~2026-07-15 12:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 12:21 [PATCH v2 0/3] misc: open-dice: add ACPI device discovery support Song Guo
2026-07-15 12:21 ` Song Guo [this message]
2026-07-15 12:21 ` [PATCH v2 2/3] misc: open-dice: save mem_base and mem_size in drvdata Song Guo
2026-07-15 12:21 ` [PATCH v2 3/3] misc: open-dice: add ACPI device discovery support Song Guo
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=20260715122146.4069884-2-songguo@google.com \
--to=songguo@google.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®