Message ID | 20231129134716.34161-1-liuhaoran14@163.com |
---|---|
State | New |
Headers | show |
Series | [power/reset] qnap-poweroff: Add error handling | expand |
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);
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(+)