]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
mei: remove support for broken parallel read
authorAlexander Usyskin <alexander.usyskin@intel.com>
Tue, 7 Feb 2017 22:41:45 +0000 (00:41 +0200)
committerTim Gardner <tim.gardner@canonical.com>
Mon, 13 Mar 2017 21:20:54 +0000 (15:20 -0600)
BugLink: http://bugs.launchpad.net/bugs/1672544
commit cb97fbbcac15982406e0c74cd5512a8b6fcf10b3 upstream.

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.

Fixes: ff1586a7ea57 ("mei: enqueue consecutive reads")
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>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/misc/mei/main.c

index e1bf54481fd682f0477211190726908e9933b349..9d0b7050c79a36698db92c9df113a15855fac4d4 100644 (file)
@@ -182,32 +182,36 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
                goto out;
        }
 
-       if (rets == -EBUSY &&
-           !mei_cl_enqueue_ctrl_wr_cb(cl, length, MEI_FOP_READ, file)) {
-               rets = -ENOMEM;
-               goto out;
-       }
 
-       do {
-               mutex_unlock(&dev->device_lock);
-
-               if (wait_event_interruptible(cl->rx_wait,
-                                            (!list_empty(&cl->rd_completed)) ||
-                                            (!mei_cl_is_connected(cl)))) {
+again:
+       mutex_unlock(&dev->device_lock);
+       if (wait_event_interruptible(cl->rx_wait,
+                                    !list_empty(&cl->rd_completed) ||
+                                    !mei_cl_is_connected(cl))) {
+               if (signal_pending(current))
+                       return -EINTR;
+               return -ERESTARTSYS;
+       }
+       mutex_lock(&dev->device_lock);
 
-                       if (signal_pending(current))
-                               return -EINTR;
-                       return -ERESTARTSYS;
-               }
+       if (!mei_cl_is_connected(cl)) {
+               rets = -ENODEV;
+               goto out;
+       }
 
-               mutex_lock(&dev->device_lock);
-               if (!mei_cl_is_connected(cl)) {
-                       rets = -ENODEV;
-                       goto out;
-               }
+       cb = mei_cl_read_cb(cl, file);
+       if (!cb) {
+               /*
+                * 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);
-       } while (!cb);
+               rets = 0;
+               goto out;
+       }
 
 copy_buffer:
        /* now copy the data to user space */