linux/drivers/phy/ti
Hans de Goede 25b3498485 phy: ti: tusb1210: Resolve charger-det crash if charger psy is unregistered
[ Upstream commit bf6e4ee5c4 ]

The power_supply frame-work is not really designed for there to be
long living in kernel references to power_supply devices.

Specifically unregistering a power_supply while some other code has
a reference to it triggers a WARN in power_supply_unregister():

	WARN_ON(atomic_dec_return(&psy->use_cnt));

Folllowed by the power_supply still getting removed and the
backing data freed anyway, leaving the tusb1210 charger-detect code
with a dangling reference, resulting in a crash the next time
tusb1210_get_online() is called.

Fix this by only holding the reference in tusb1210_get_online()
freeing it at the end of the function. Note this still leaves
a theoretical race window, but it avoids the issue when manually
rmmod-ing the charger chip driver during development.

Fixes: 48969a5623 ("phy: ti: tusb1210: Add charger detection")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240406140821.18624-1-hdegoede@redhat.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2024-05-02 16:29:31 +02:00
..
Kconfig phy: ti: fix Kconfig warning and operator precedence 2023-02-01 08:34:08 +01:00
Makefile phy: ti: j721e-wiz: Add support for WIZ module present in TI J721E SoC 2020-01-14 10:50:19 +05:30
phy-am654-serdes.c phy: ti: Add missing pm_runtime_disable() in serdes_am654_probe 2022-04-14 10:38:58 +05:30
phy-da8xx-usb.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 285 2019-06-05 17:36:37 +02:00
phy-dm816x-usb.c treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_30.RULE (part 2) 2022-06-10 14:51:35 +02:00
phy-gmii-sel.c phy: ti: gmii-sel: Add support for CPSW5G GMII SEL in J7200 2022-09-13 23:10:26 +05:30
phy-j721e-wiz.c phy: ti: j721e-wiz: Fix unreachable code in wiz_mode_select() 2023-05-11 23:03:37 +09:00
phy-omap-control.c phy: ti: Use IS_ERR_OR_NULL() to clean code 2021-12-14 13:10:03 +05:30
phy-omap-usb2.c phy: ti: phy-omap-usb2: Fix NULL pointer dereference for SRP 2024-02-16 19:06:25 +01:00
phy-ti-pipe3.c phy: ti: Fix missing of_node_put in ti_pipe3_get_sysctrl() 2022-04-11 22:45:31 +05:30
phy-tusb1210.c phy: ti: tusb1210: Resolve charger-det crash if charger psy is unregistered 2024-05-02 16:29:31 +02:00
phy-twl4030-usb.c phy: phy-twl4030-usb: Disable PHY for suspend 2021-08-06 17:32:51 +05:30