lkml.org 
[lkml]   [2023]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] [power/reset] qnap-poweroff: Add error handling
Date
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@163.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
\
 
 \ /
  Last update: 2023-11-29 14:47    [W:0.122 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site