From 037116a6cca3e4dbc97905b6e254e8fe7475d502 Mon Sep 17 00:00:00 2001 From: Zijun Hu Date: Sun, 5 Jan 2025 16:34:06 +0800 Subject: [PATCH] driver core: Correct parameter check for API device_for_each_child_reverse_from() device_for_each_child_reverse_from() checks (!parent->p) for its parameter @parent, and that is not consistent with other APIs of its cluster as shown below: device_for_each_child_reverse_from() // check (!parent->p) device_for_each_child_reverse() // check (!parent || !parent->p) device_for_each_child() // same above device_find_child() // same above Correct the API's parameter @parent check by (!parent || !parent->p). Reviewed-by: Jonathan Cameron Signed-off-by: Zijun Hu Link: https://lore.kernel.org/r/20250105-class_fix-v6-5-3a2f1768d4d4@quicinc.com Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index a83a1350fb5b2..d3800f0dc5bbd 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4050,7 +4050,7 @@ int device_for_each_child_reverse_from(struct device *parent, struct device *child; int error = 0; - if (!parent->p) + if (!parent || !parent->p) return 0; klist_iter_init_node(&parent->p->klist_children, &i, -- 2.47.2