Skip to content

Commit 903c449

Browse files
zijun-hugregkh
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8ab0f46 commit 903c449

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/base/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3998,7 +3998,7 @@ int device_for_each_child(struct device *parent, void *data,
39983998
struct device *child;
39993999
int error = 0;
40004000

4001-
if (!parent->p)
4001+
if (!parent || !parent->p)
40024002
return 0;
40034003

40044004
klist_iter_init(&parent->p->klist_children, &i);
@@ -4028,7 +4028,7 @@ int device_for_each_child_reverse(struct device *parent, void *data,
40284028
struct device *child;
40294029
int error = 0;
40304030

4031-
if (!parent->p)
4031+
if (!parent || !parent->p)
40324032
return 0;
40334033

40344034
klist_iter_init(&parent->p->klist_children, &i);
@@ -4062,7 +4062,7 @@ struct device *device_find_child(struct device *parent, void *data,
40624062
struct klist_iter i;
40634063
struct device *child;
40644064

4065-
if (!parent)
4065+
if (!parent || !parent->p)
40664066
return NULL;
40674067

40684068
klist_iter_init(&parent->p->klist_children, &i);

0 commit comments

Comments
 (0)