In the Linux kernel, the following vulnerability has been resolved:
phy: ti: tusb1210: Resolve charger-det crash if charger psy is unregistered
The powersupply frame-work is not really designed for there to be long living in kernel references to powersupply devices.
Specifically unregistering a powersupply while some other code has a reference to it triggers a WARN in powersupply_unregister():
WARN_ON(atomic_dec_return(&psy->use_cnt));
Folllowed by the powersupply 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 tusb1210get_online() is called.
Fix this by only holding the reference in tusb1210getonline() 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.