* [PATCH] openprom: Add NULL check for pdev in oprompci2node()
@ 2025-07-23 4:07 Chenyuan Yang
0 siblings, 0 replies; only message in thread
From: Chenyuan Yang @ 2025-07-23 4:07 UTC (permalink / raw)
To: davem, andreas, viro, chenyuan0y; +Cc: sparclinux, linux-kernel
Since pci_get_domain_bus_and_slot() can return NULL,
add NULL check for pdev in oprompci2node().
This change is similar to the fix implemented in commit 9af152dcf1a0
("drm/gma500: Add NULL check for pci_gfx_root in mid_get_vbt_data()").
Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
---
drivers/sbus/char/openprom.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index 8643947fee8e..e6f3082569fc 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -241,6 +241,8 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp
pdev = pci_get_domain_bus_and_slot(0,
((int *) op->oprom_array)[0],
((int *) op->oprom_array)[1]);
+ if (!pdev)
+ return -ENODEV;
dp = pci_device_to_OF_node(pdev);
data->current_node = dp;
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-07-23 4:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-23 4:07 [PATCH] openprom: Add NULL check for pdev in oprompci2node() Chenyuan Yang
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).