Skip to content

Commit e728ae2

Browse files
ausyskingregkh
authored andcommitted
mei: amthif: fix deadlock in initialization during a reset
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") Cc: <[email protected]> # 4.6+ Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 80293c4 commit e728ae2

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
@@ -66,8 +66,12 @@ int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
6666
struct mei_cl *cl = &dev->iamthif_cl;
6767
int ret;
6868

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

7276
dev->iamthif_state = MEI_IAMTHIF_IDLE;
7377

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

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

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

drivers/misc/mei/bus.c

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

987-
mutex_lock(&bus->device_lock);
988987
me_cl = mei_me_cl_by_uuid(bus, &mei_amthif_guid);
989988
if (me_cl)
990989
mei_amthif_host_init(bus, me_cl);
991990
mei_me_cl_put(me_cl);
992-
mutex_unlock(&bus->device_lock);
993991

994992
mei_cl_bus_rescan(bus);
995993
}

0 commit comments

Comments
 (0)