From: Chenyuan Yang <chenyuan0y@gmail.com>
To: davem@davemloft.net, andreas@gaisler.com,
viro@zeniv.linux.org.uk, chenyuan0y@gmail.com
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] openprom: Add NULL check for pdev in oprompci2node()
Date: Tue, 22 Jul 2025 23:07:53 -0500 [thread overview]
Message-ID: <20250723040753.3231242-1-chenyuan0y@gmail.com> (raw)
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
reply other threads:[~2025-07-23 4:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250723040753.3231242-1-chenyuan0y@gmail.com \
--to=chenyuan0y@gmail.com \
--cc=andreas@gaisler.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=sparclinux@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).