Skip to content

Commit ce1b3a4

Browse files
ruanjinjiegregkh
authored andcommitted
of: overlay: fix null pointer dereferencing in find_dup_cset_node_entry() and find_dup_cset_prop()
[ Upstream commit ee9d7a0 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 8399b98 commit ce1b3a4

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
@@ -547,7 +547,7 @@ static int find_dup_cset_node_entry(struct overlay_changeset *ovcs,
547547

548548
fn_1 = kasprintf(GFP_KERNEL, "%pOF", ce_1->np);
549549
fn_2 = kasprintf(GFP_KERNEL, "%pOF", ce_2->np);
550-
node_path_match = !strcmp(fn_1, fn_2);
550+
node_path_match = !fn_1 || !fn_2 || !strcmp(fn_1, fn_2);
551551
kfree(fn_1);
552552
kfree(fn_2);
553553
if (node_path_match) {
@@ -582,7 +582,7 @@ static int find_dup_cset_prop(struct overlay_changeset *ovcs,
582582

583583
fn_1 = kasprintf(GFP_KERNEL, "%pOF", ce_1->np);
584584
fn_2 = kasprintf(GFP_KERNEL, "%pOF", ce_2->np);
585-
node_path_match = !strcmp(fn_1, fn_2);
585+
node_path_match = !fn_1 || !fn_2 || !strcmp(fn_1, fn_2);
586586
kfree(fn_1);
587587
kfree(fn_2);
588588
if (node_path_match &&

0 commit comments

Comments
 (0)