OSDN Git Service

power: supply: twl4030-charger: fix OF sibling-node lookup
authorJohan Hovold <johan@kernel.org>
Mon, 27 Aug 2018 08:21:53 +0000 (10:21 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2018 19:08:51 +0000 (11:08 -0800)
commit168945fe47d109df0bf327c5d09a03e74c5e6802
treeccb37840d59cdd906f754b4445d81291e6c0fdf8
parent65635b7d4dd7c0f74c3f476b4972c1202e6e9c4f
power: supply: twl4030-charger: fix OF sibling-node lookup

commit 9844fb2e351311210e6660a9a1c62d17424a6145 upstream.

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: f5e4edb8c888 ("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: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/power/supply/twl4030_charger.c