• Johan Hovold's avatar
    power: supply: twl4030-charger: fix OF sibling-node lookup · 9844fb2e
    Johan Hovold authored
    Use the new of_get_compatible_child() helper to lookup the usb sibling
    node instead of using of_find_compatible_node(), which searches the
    entire tree from a given start node and thus can return an unrelated
    (non-sibling) node.
    
    This also addresses a potential use-after-free (e.g. after probe
    deferral) as the tree-wide helper drops a reference to its first
    argument (i.e. the parent device node).
    
    While at it, also fix the related phy-node reference leak.
    
    Fixes: f5e4edb8 ("power: twl4030_charger: find associated phy by more reliable means.")
    Cc: stable <stable@vger.kernel.org>     # 4.2
    Cc: NeilBrown <neilb@suse.de>
    Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
    Cc: Sebastian Reichel <sre@kernel.org>
    Reviewed-by: default avatarSebastian Reichel <sre@kernel.org>
    Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
    Signed-off-by: default avatarRob Herring <robh@kernel.org>
    9844fb2e
twl4030_charger.c 28.5 KB