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

From: Haoran Liu
Date: Wed Nov 29 2023 - 09:11:18 EST


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@xxxxxxx>
---
drivers/ufs/host/tc-dwc-g210-pltfrm.c | 5 +++++
1 file changed, 5 insertions(+)

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 */
--
2.17.1