Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

driver core: Make parameter check consistent for API cluster device_(for_each|find)_child()

The following API cluster takes the same type parameter list, but do not
have consistent parameter check as shown below.

device_for_each_child(struct device *parent, ...) // check (!parent->p)
device_for_each_child_reverse(struct device *parent, ...) // same as above
device_find_child(struct device *parent, ...) // check (!parent)

Fixed by using consistent check (!parent || !parent->p) which covers
both existing checks for the cluster.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20240824-const_dfc_prepare-v3-1-32127ea32bba@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Zijun Hu and committed by
Greg Kroah-Hartman
903c4493 8ab0f460

+3 -3
+3 -3
drivers/base/core.c
··· 3998 3998 struct device *child; 3999 3999 int error = 0; 4000 4000 4001 - if (!parent->p) 4001 + if (!parent || !parent->p) 4002 4002 return 0; 4003 4003 4004 4004 klist_iter_init(&parent->p->klist_children, &i); ··· 4028 4028 struct device *child; 4029 4029 int error = 0; 4030 4030 4031 - if (!parent->p) 4031 + if (!parent || !parent->p) 4032 4032 return 0; 4033 4033 4034 4034 klist_iter_init(&parent->p->klist_children, &i); ··· 4062 4062 struct klist_iter i; 4063 4063 struct device *child; 4064 4064 4065 - if (!parent) 4065 + if (!parent || !parent->p) 4066 4066 return NULL; 4067 4067 4068 4068 klist_iter_init(&parent->p->klist_children, &i);