diff mbox series

[ufs] tc-dwc-g210: Add error handling in tc_dwc_g210_pltfm_probe

Message ID 20231129141041.34275-1-liuhaoran14@163.com
State New
Headers show
Series [ufs] tc-dwc-g210: Add error handling in tc_dwc_g210_pltfm_probe | expand

Commit Message

Haoran Liu Nov. 29, 2023, 2:10 p.m. UTC
This patch adds error handling for the of_match_node call in the
tc_dwc_g210_pltfm_probe function within
drivers/ufs/host/tc-dwc-g210-pltfrm.c. Previously, the function did
not properly handle a null return value from of_match_node, which could
lead to issues if the device tree matching failed.

Signed-off-by: Haoran Liu <liuhaoran14@163.com>
---
 drivers/ufs/host/tc-dwc-g210-pltfrm.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/drivers/ufs/host/tc-dwc-g210-pltfrm.c b/drivers/ufs/host/tc-dwc-g210-pltfrm.c
index a3877592604d..991069bfe570 100644
--- a/drivers/ufs/host/tc-dwc-g210-pltfrm.c
+++ b/drivers/ufs/host/tc-dwc-g210-pltfrm.c
@@ -59,6 +59,11 @@  static int tc_dwc_g210_pltfm_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 
 	of_id = of_match_node(tc_dwc_g210_pltfm_match, dev->of_node);
+	if (!of_id) {
+		dev_err(dev, "No matching device found\n");
+		return -ENODEV;
+	}
+
 	vops = (struct ufs_hba_variant_ops *)of_id->data;
 
 	/* Perform generic probe */