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.8.0-rc2~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e039f5faefa0bdfda6253eb2e67bb970d10a5c67;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 c0142071..b908ed06 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 d18967d6..16001776 100644 --- a/lib/ringbuffer/backend_internal.h +++ b/lib/ringbuffer/backend_internal.h @@ -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, diff --git a/lib/ringbuffer/ring_buffer_backend.c b/lib/ringbuffer/ring_buffer_backend.c index f34c7ccc..451ce23b 100644 --- a/lib/ringbuffer/ring_buffer_backend.c +++ b/lib/ringbuffer/ring_buffer_backend.c @@ -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 */ }