> From: Tarun Sahu <[email protected]> > > In Async device shutdown, device_kset->list lock is released to handle > asynchronisation and hold again to get entry from device_kset->list. > Which will leave window when device_add can try to add the device to > device_kset list and temper with ongoing shutdown process. New added > device can be async type or sync type and might also introduce new > dependency which can cause device_shutdown path to deadlock. S is > waiting C to finish but C is never scheduled as it was added recently > from device_add path. And C can only be scheduled when main loops > continue to reach to C which is waiting on S. > > So, When a system enters shutdown (SYSTEM_HALT, SYSTEM_POWER_OFF, or > SYSTEM_RESTART), new devices should not be allowed to be added. > Adding system_state check (system_is_shutting_down()) to avoid > device_add incase of these states of the system. And use srcu so the > device shutdown operation can synchronize device_add and ensure any > device_add in progress is finished. > > Signed-off-by: Tarun Sahu <[email protected]> > Signed-off-by: David Jeffery <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2
