Fix: lib_ring_buffer_copy_from_user_inatomic error handling
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 20 Apr 2016 21:56:45 +0000 (17:56 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 20 Apr 2016 22:02:57 +0000 (18:02 -0400)
It should treat nonzero return value of
lib_ring_buffer_do_copy_from_user_inatomic() as errors, 0 as success.

It is currently unused by the instrumentation.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/backend.h
lib/ringbuffer/backend_internal.h
lib/ringbuffer/ring_buffer_backend.c

index e3a0a81afb7a5b6f8bc327dce3c3847ec0a8e0b1..61b7f5394a3ed7be63f73f75c83249b7ce7f2bcb 100644 (file)
@@ -334,8 +334,7 @@ void lib_ring_buffer_copy_from_user_inatomic(const struct lib_ring_buffer_config
                        rpages->p[index].virt + (offset & ~PAGE_MASK),
                        src, len);
                if (unlikely(ret > 0)) {
-                       len -= (pagecpy - ret);
-                       offset += (pagecpy - ret);
+                       /* Copy failed. */
                        goto fill_buffer;
                }
        } else {
index 35b26f77190edb9d1588f9ace92866f304fe1053..9ee7091696ae1c625d4a16b75056512771e1e8e9 100644 (file)
@@ -443,6 +443,8 @@ do {                                                                \
 /*
  * We use __copy_from_user_inatomic to copy userspace data since we already
  * did the access_ok for the whole range.
+ *
+ * Return 0 if OK, nonzero on error.
  */
 static inline
 unsigned long lib_ring_buffer_do_copy_from_user_inatomic(void *dest,
index 3cc22d77b2d9ad5c2ed428fed783b9055a5f97d3..5417648af78c446637623dcf5d0e4a9e446d6d42 100644 (file)
@@ -692,8 +692,7 @@ void _lib_ring_buffer_copy_from_user_inatomic(struct lib_ring_buffer_backend *bu
                                                        + (offset & ~PAGE_MASK),
                                                        src, pagecpy) != 0;
                if (ret > 0) {
-                       offset += (pagecpy - ret);
-                       len -= (pagecpy - ret);
+                       /* Copy failed. */
                        _lib_ring_buffer_memset(bufb, offset, 0, len, 0);
                        break; /* stop copy */
                }
This page took 0.027849 seconds and 4 git commands to generate.