Skip to content

Commit 97a19db

Browse files
ausyskingregkh
authored andcommitted
mei: amthif: fix deadlock in initialization during a reset
commit e728ae2 upstream. The device lock was unnecessary obtained in bus rescan work before the amthif client search. That causes incorrect lock ordering and task hang: ... [88004.613213] INFO: task kworker/1:14:21832 blocked for more than 120 seconds. ... [88004.645934] Workqueue: events mei_cl_bus_rescan_work ... The correct lock order is cl_bus_lock device_lock me_clients_rwsem Move device_lock into amthif init function that called after me_clients_rwsem is released. This fixes regression introduced by commit: commit 025fb79 ("mei: split amthif client init from end of clients enumeration") Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 21fe8c7 commit 97a19db

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

drivers/misc/mei/amthif.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
6767
struct mei_cl *cl = &dev->iamthif_cl;
6868
int ret;
6969

70-
if (mei_cl_is_connected(cl))
71-
return 0;
70+
mutex_lock(&dev->device_lock);
71+
72+
if (mei_cl_is_connected(cl)) {
73+
ret = 0;
74+
goto out;
75+
}
7276

7377
dev->iamthif_state = MEI_IAMTHIF_IDLE;
7478

@@ -77,11 +81,13 @@ int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
7781
ret = mei_cl_link(cl);
7882
if (ret < 0) {
7983
dev_err(dev->dev, "amthif: failed cl_link %d\n", ret);
80-
return ret;
84+
goto out;
8185
}
8286

8387
ret = mei_cl_connect(cl, me_cl, NULL);
8488

89+
out:
90+
mutex_unlock(&dev->device_lock);
8591
return ret;
8692
}
8793

drivers/misc/mei/bus.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,12 +983,10 @@ void mei_cl_bus_rescan_work(struct work_struct *work)
983983
container_of(work, struct mei_device, bus_rescan_work);
984984
struct mei_me_client *me_cl;
985985

986-
mutex_lock(&bus->device_lock);
987986
me_cl = mei_me_cl_by_uuid(bus, &mei_amthif_guid);
988987
if (me_cl)
989988
mei_amthif_host_init(bus, me_cl);
990989
mei_me_cl_put(me_cl);
991-
mutex_unlock(&bus->device_lock);
992990

993991
mei_cl_bus_rescan(bus);
994992
}

0 commit comments

Comments
 (0)