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:53 +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 c0142071666bed5df347b3ab96d3762e9830ddf9..b908ed06e92665e127bac42e19d57ffbb7ec9670 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 d18967d6738d48721eed9d1471c0140d02b99629..16001776f6ebcc4b9477c427a868509b9bc5c387 100644 (file)
@@ -451,6 +451,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 f34c7ccc4ce7e6096171ba5cd55877a0e39fa908..451ce23b2eb51f5eca72dcd3a01a26097b5b1986 100644 (file)
@@ -693,8 +693,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.031068 seconds and 4 git commands to generate.