From b072266078c9dfc3e59022c79575bd37796bb0bd Mon Sep 17 00:00:00 2001 From: Song Guo Date: Wed, 15 Jul 2026 12:21:44 +0000 Subject: [PATCH] misc: open-dice: do not assume dev->of_node is valid 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 Link: https://patch.msgid.link/20260715122146.4069884-2-songguo@google.com Signed-off-by: Greg Kroah-Hartman --- 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; }