Skip to content

Commit ee9d7a0

Browse files
ruanjinjierobherring
authored andcommitted
of: overlay: fix null pointer dereferencing in find_dup_cset_node_entry() and find_dup_cset_prop()
When kmalloc() fail to allocate memory in kasprintf(), fn_1 or fn_2 will be NULL, and strcmp() will cause null pointer dereference. Fixes: 2fe0e87 ("of: overlay: check prevents multiple fragments touching same property") Signed-off-by: ruanjinjie <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring <[email protected]>
1 parent 0387106 commit ee9d7a0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/of/overlay.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static int find_dup_cset_node_entry(struct overlay_changeset *ovcs,
545545

546546
fn_1 = kasprintf(GFP_KERNEL, "%pOF", ce_1->np);
547547
fn_2 = kasprintf(GFP_KERNEL, "%pOF", ce_2->np);
548-
node_path_match = !strcmp(fn_1, fn_2);
548+
node_path_match = !fn_1 || !fn_2 || !strcmp(fn_1, fn_2);
549549
kfree(fn_1);
550550
kfree(fn_2);
551551
if (node_path_match) {
@@ -580,7 +580,7 @@ static int find_dup_cset_prop(struct overlay_changeset *ovcs,
580580

581581
fn_1 = kasprintf(GFP_KERNEL, "%pOF", ce_1->np);
582582
fn_2 = kasprintf(GFP_KERNEL, "%pOF", ce_2->np);
583-
node_path_match = !strcmp(fn_1, fn_2);
583+
node_path_match = !fn_1 || !fn_2 || !strcmp(fn_1, fn_2);
584584
kfree(fn_1);
585585
kfree(fn_2);
586586
if (node_path_match &&

0 commit comments

Comments
 (0)