Skip to content

Commit

Permalink
powerpc/8xx: Fix possible device node reference leak
Browse files Browse the repository at this point in the history
The call to of_find_compatible_node() returns a node pointer with
refcount incremented thus it must be explicitly decremented after the
last usage.

irq_domain_add_linear() also calls of_node_get() to increase refcount,
so irq_domain() will not be affected when it is released.

Detected by coccinelle.

Fixes: a8db8cf ("irq_domain: Replace irq_alloc_host() with revmap-specific initializers")
Signed-off-by: Wen Yang <[email protected]>
Suggested-by: Christophe Leroy <[email protected]>
Suggested-by: Michael Ellerman <[email protected]>
Reviewed-by: Peng Hao <[email protected]>
Reviewed-by: Christophe Leroy <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
taskset authored and mpe committed Apr 20, 2019
1 parent 7f177f9 commit cc76404
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions arch/powerpc/platforms/8xx/pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,9 @@ int mpc8xx_pic_init(void)
if (mpc8xx_pic_host == NULL) {
printk(KERN_ERR "MPC8xx PIC: failed to allocate irq host!\n");
ret = -ENOMEM;
goto out;
}
return 0;

ret = 0;
out:
of_node_put(np);
return ret;
Expand Down

0 comments on commit cc76404

Please sign in to comment.