mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] edd: Add null checks for edev and info in edd_get_pci_dev
@ 2024-09-04 15:15 Riyan Dhiman
  0 siblings, 0 replies; only message in thread
From: Riyan Dhiman @ 2024-09-04 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Riyan Dhiman

Add null check for edev in the edd_get_pci_dev function
to prevent potential null pointer dereference. This check ensure
that the function safely handles cases where edev might be NULL,
avoiding possible crashes.

Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
---
 drivers/firmware/edd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 55dec4eb2c00..6964e528bf35 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -648,7 +648,10 @@ edd_dev_is_type(struct edd_device *edev, const char *type)
 static struct pci_dev *
 edd_get_pci_dev(struct edd_device *edev)
 {
-	struct edd_info *info = edd_dev_get_info(edev);
+	struct edd_info *info;
+	if(!edev)
+		return NULL;
+	info = edd_dev_get_info(edev);
 
 	if (edd_dev_is_type(edev, "PCI") || edd_dev_is_type(edev, "XPRS")) {
 		return pci_get_domain_bus_and_slot(0,
-- 
2.46.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-09-04 15:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-04 15:15 [PATCH] edd: Add null checks for edev and info in edd_get_pci_dev Riyan Dhiman

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®