Merge tag 'hwlock-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson...
[linux-2.6-microblaze.git] / samples / kfifo / inttype-example.c
index 78977fc..e5403d8 100644 (file)
@@ -115,8 +115,10 @@ static ssize_t fifo_write(struct file *file, const char __user *buf,
        ret = kfifo_from_user(&test, buf, count, &copied);
 
        mutex_unlock(&write_lock);
+       if (ret)
+               return ret;
 
-       return ret ? ret : copied;
+       return copied;
 }
 
 static ssize_t fifo_read(struct file *file, char __user *buf,
@@ -131,8 +133,10 @@ static ssize_t fifo_read(struct file *file, char __user *buf,
        ret = kfifo_to_user(&test, buf, count, &copied);
 
        mutex_unlock(&read_lock);
+       if (ret)
+               return ret;
 
-       return ret ? ret : copied;
+       return copied;
 }
 
 static const struct proc_ops fifo_proc_ops = {