From: Daniel De Graaf Date: Wed, 8 Sep 2010 22:10:42 +0000 (-0400) Subject: xenbus: avoid zero returns from read() X-Git-Tag: v2.6.38-rc2~22^2~1 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7808121b9a1e44ef12fecd49fa6c268f27a150fc;p=karo-tx-linux.git xenbus: avoid zero returns from read() It is possible to get a zero return from read() in instances where the queue is not empty but has no elements with data to deliver to the user. Since a zero return from read is an error indicator, resume waiting or return -EAGAIN (for a nonblocking fd) in this case. Signed-off-by: Daniel De Graaf Signed-off-by: Jeremy Fitzhardinge --- diff --git a/drivers/xen/xenfs/xenbus.c b/drivers/xen/xenfs/xenbus.c index c4c7db8363e7..55791dd1105f 100644 --- a/drivers/xen/xenfs/xenbus.c +++ b/drivers/xen/xenfs/xenbus.c @@ -120,6 +120,7 @@ static ssize_t xenbus_file_read(struct file *filp, int ret; mutex_lock(&u->reply_mutex); +again: while (list_empty(&u->read_buffers)) { mutex_unlock(&u->reply_mutex); if (filp->f_flags & O_NONBLOCK) @@ -158,6 +159,8 @@ static ssize_t xenbus_file_read(struct file *filp, struct read_buffer, list); } } + if (i == 0) + goto again; out: mutex_unlock(&u->reply_mutex);