Skip to content

Commit d9a0a05

Browse files
committed
gpu: host1x: Detach driver on unregister
Currently when a host1x device driver is unregistered, it is not detached from the host1x controller, which means that the device will stay around and when the driver is registered again, it may bind to the old, stale device rather than the new one that was created from scratch upon driver registration. This in turn can cause various weird crashes within the driver core because it is confronted with a device that was already deleted. Fix this by detaching the driver from the host1x controller when it is unregistered. This ensures that the deleted device also is no longer present in the device list that drivers will bind to. Reported-by: Sowjanya Komatineni <[email protected]> Signed-off-by: Thierry Reding <[email protected]> Tested-by: Sowjanya Komatineni <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 2fd2bc7 commit d9a0a05

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/gpu/host1x/bus.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,17 @@ EXPORT_SYMBOL(host1x_driver_register_full);
686686
*/
687687
void host1x_driver_unregister(struct host1x_driver *driver)
688688
{
689+
struct host1x *host1x;
690+
689691
driver_unregister(&driver->driver);
690692

693+
mutex_lock(&devices_lock);
694+
695+
list_for_each_entry(host1x, &devices, list)
696+
host1x_detach_driver(host1x, driver);
697+
698+
mutex_unlock(&devices_lock);
699+
691700
mutex_lock(&drivers_lock);
692701
list_del_init(&driver->list);
693702
mutex_unlock(&drivers_lock);

0 commit comments

Comments
 (0)