Skip to content

Commit bc46b45

Browse files
ausyskingregkh
authored andcommitted
mei: bus: call mei_cl_read_start under device lock
Ensure that mei_cl_read_start is called under the device lock also in the bus layer. The function updates global ctrl_wr_list which should be locked. Cc: <stable@vger.kernel.org> raspberrypi#4.4+ Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bedffda commit bc46b45

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎drivers/misc/mei/bus.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,23 @@ EXPORT_SYMBOL_GPL(mei_cldev_recv);
220220
static void mei_cl_bus_event_work(struct work_struct *work)
221221
{
222222
struct mei_cl_device *cldev;
223+
struct mei_device *bus;
223224

224225
cldev = container_of(work, struct mei_cl_device, event_work);
225226

227+
bus = cldev->bus;
228+
226229
if (cldev->event_cb)
227230
cldev->event_cb(cldev, cldev->events, cldev->event_context);
228231

229232
cldev->events = 0;
230233

231234
/* Prepare for the next read */
232-
if (cldev->events_mask & BIT(MEI_CL_EVENT_RX))
235+
if (cldev->events_mask & BIT(MEI_CL_EVENT_RX)) {
236+
mutex_lock(&bus->device_lock);
233237
mei_cl_read_start(cldev->cl, 0, NULL);
238+
mutex_unlock(&bus->device_lock);
239+
}
234240
}
235241

236242
/**
@@ -304,6 +310,7 @@ int mei_cldev_register_event_cb(struct mei_cl_device *cldev,
304310
unsigned long events_mask,
305311
mei_cldev_event_cb_t event_cb, void *context)
306312
{
313+
struct mei_device *bus = cldev->bus;
307314
int ret;
308315

309316
if (cldev->event_cb)
@@ -316,15 +323,17 @@ int mei_cldev_register_event_cb(struct mei_cl_device *cldev,
316323
INIT_WORK(&cldev->event_work, mei_cl_bus_event_work);
317324

318325
if (cldev->events_mask & BIT(MEI_CL_EVENT_RX)) {
326+
mutex_lock(&bus->device_lock);
319327
ret = mei_cl_read_start(cldev->cl, 0, NULL);
328+
mutex_unlock(&bus->device_lock);
320329
if (ret && ret != -EBUSY)
321330
return ret;
322331
}
323332

324333
if (cldev->events_mask & BIT(MEI_CL_EVENT_NOTIF)) {
325-
mutex_lock(&cldev->cl->dev->device_lock);
334+
mutex_lock(&bus->device_lock);
326335
ret = mei_cl_notify_request(cldev->cl, NULL, event_cb ? 1 : 0);
327-
mutex_unlock(&cldev->cl->dev->device_lock);
336+
mutex_unlock(&bus->device_lock);
328337
if (ret)
329338
return ret;
330339
}

0 commit comments

Comments
 (0)