From: Mathieu Desnoyers Date: Wed, 20 Apr 2016 21:56:45 +0000 (-0400) Subject: Fix: lib_ring_buffer_copy_from_user_inatomic error handling X-Git-Tag: v2.7.3~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6115dd20b489d0c9bdec7c7d5299770605697ca8;p=lttng-modules.git Fix: lib_ring_buffer_copy_from_user_inatomic error handling 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 --- diff --git a/lib/ringbuffer/backend.h b/lib/ringbuffer/backend.h index e3a0a81a..61b7f539 100644 --- a/lib/ringbuffer/backend.h +++ b/lib/ringbuffer/backend.h @@ -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 { diff --git a/lib/ringbuffer/backend_internal.h b/lib/ringbuffer/backend_internal.h index 35b26f77..9ee70916 100644 --- a/lib/ringbuffer/backend_internal.h +++ b/lib/ringbuffer/backend_internal.h @@ -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, diff --git a/lib/ringbuffer/ring_buffer_backend.c b/lib/ringbuffer/ring_buffer_backend.c index 3cc22d77..5417648a 100644 --- a/lib/ringbuffer/ring_buffer_backend.c +++ b/lib/ringbuffer/ring_buffer_backend.c @@ -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 */ }