linux-stable/drivers/phy/ti
Hans de Goede 9827caa510 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>
2024-05-02 16:35:34 +02:00
..
Kconfig phy: ti: fix Kconfig warning and operator precedence 2023-01-11 13:24:33 +05:30
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: am654-serdes: Add a determine_rate hook 2023-06-08 18:39:31 -07:00
phy-da8xx-usb.c phy: ti: phy-da8xx-usb: Convert to platform remove callback returning void 2023-03-20 18:14:58 +05:30
phy-dm816x-usb.c phy: Drop unnecessary of_match_device() calls 2023-10-13 15:47:53 +05:30
phy-gmii-sel.c phy-for-6.8 2024-01-18 17:11:43 -08:00
phy-j721e-wiz.c phy: ti: j721e-wiz: Add SGMII support in WIZ driver for J784S4 2023-12-22 21:20:08 +05:30
phy-omap-control.c phy: Use device_get_match_data() 2023-10-13 15:45:40 +05:30
phy-omap-usb2.c phy: ti: phy-omap-usb2: Fix NULL pointer dereference for SRP 2024-01-30 22:41:11 +05:30
phy-ti-pipe3.c phy: Use device_get_match_data() 2023-10-13 15:45:40 +05:30
phy-tusb1210.c phy: ti: tusb1210: Resolve charger-det crash if charger psy is unregistered 2024-05-02 16:35:34 +02:00
phy-twl4030-usb.c phy: Explicitly include correct DT includes 2023-07-17 11:52:56 +05:30