Commit cb97fbbc authored by Alexander Usyskin's avatar Alexander Usyskin Committed by Greg Kroah-Hartman

mei: remove support for broken parallel read

Parallel reads from multiple threads on a file descriptor
are not well defined and racy. It is safer to return to original
behavior and simply fail the additional read.
The solution is to remove request for next read credit.

Cc: <stable@vger.kernel.org> #4.9
Fixes: ff1586a7 ("mei: enqueue consecutive reads")
Signed-off-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dd37eed7
...@@ -182,32 +182,36 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, ...@@ -182,32 +182,36 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
goto out; goto out;
} }
if (rets == -EBUSY &&
!mei_cl_enqueue_ctrl_wr_cb(cl, length, MEI_FOP_READ, file)) {
rets = -ENOMEM;
goto out;
}
do { again:
mutex_unlock(&dev->device_lock); mutex_unlock(&dev->device_lock);
if (wait_event_interruptible(cl->rx_wait,
if (wait_event_interruptible(cl->rx_wait, !list_empty(&cl->rd_completed) ||
(!list_empty(&cl->rd_completed)) || !mei_cl_is_connected(cl))) {
(!mei_cl_is_connected(cl)))) { if (signal_pending(current))
return -EINTR;
return -ERESTARTSYS;
}
mutex_lock(&dev->device_lock);
if (signal_pending(current)) if (!mei_cl_is_connected(cl)) {
return -EINTR; rets = -ENODEV;
return -ERESTARTSYS; goto out;
} }
mutex_lock(&dev->device_lock); cb = mei_cl_read_cb(cl, file);
if (!mei_cl_is_connected(cl)) { if (!cb) {
rets = -ENODEV; /*
goto out; * For amthif all the waiters are woken up,
} * but only fp with matching cb->fp get the cb,
* the others have to return to wait on read.
*/
if (cl == &dev->iamthif_cl)
goto again;
cb = mei_cl_read_cb(cl, file); rets = 0;
} while (!cb); goto out;
}
copy_buffer: copy_buffer:
/* now copy the data to user space */ /* now copy the data to user space */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment