[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20231129134716.34161-1-liuhaoran14@163.com>
Date: Wed, 29 Nov 2023 05:47:16 -0800
From: Haoran Liu <liuhaoran14@....com>
To: sre@...nel.org
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
Haoran Liu <liuhaoran14@....com>
Subject: [PATCH] [power/reset] qnap-poweroff: Add error handling
This patch introduces error handling for the of_match_node call
in the qnap_power_off_probe function within
drivers/power/reset/qnap-poweroff.c. Previously, there was no
check for a null return value from of_match_node, which could
lead to improper behavior if the device tree matching failed.
Signed-off-by: Haoran Liu <liuhaoran14@....com>
---
drivers/power/reset/qnap-poweroff.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/power/reset/qnap-poweroff.c b/drivers/power/reset/qnap-poweroff.c
index 0ddf7f25f7b8..bc0b547211d6 100644
--- a/drivers/power/reset/qnap-poweroff.c
+++ b/drivers/power/reset/qnap-poweroff.c
@@ -77,6 +77,11 @@ static int qnap_power_off_probe(struct platform_device *pdev)
const struct of_device_id *match =
of_match_node(qnap_power_off_of_match_table, np);
+ if (!match) {
+ dev_err(&pdev->dev, "No matching device found\n");
+ return -ENODEV;
+ }
+
cfg = match->data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
2.17.1
Powered by blists - more mailing lists