From: Michael Jeanson Date: Mon, 18 Mar 2019 20:20:36 +0000 (-0400) Subject: Fix: atomic_long_add_unless() returns a boolean X-Git-Tag: v2.9.13~17 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=64eff4764737408d0805a57ce95e564600e06c98;p=lttng-modules.git Fix: atomic_long_add_unless() returns a boolean Because of a documentation error in older kernels, it was assumed that atomic_long_add_unless would return the old value, but the implementation actually returns a boolean. Also add missing error code int 'ret' and compare against the right type max value. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-abi.c b/lttng-abi.c index c45c10f4..bee4255d 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -429,8 +429,8 @@ int lttng_abi_create_channel(struct file *session_file, transport_name = ""; break; } - if (atomic_long_add_unless(&session_file->f_count, - 1, INT_MAX) == INT_MAX) { + if (!atomic_long_add_unless(&session_file->f_count, 1, LONG_MAX)) { + ret = -EOVERFLOW; goto refcount_error; } /* @@ -1038,8 +1038,7 @@ int lttng_abi_create_event(struct file *channel_file, goto file_error; } /* The event holds a reference on the channel */ - if (atomic_long_add_unless(&channel_file->f_count, - 1, INT_MAX) == INT_MAX) { + if (!atomic_long_add_unless(&channel_file->f_count, 1, LONG_MAX)) { ret = -EOVERFLOW; goto refcount_error; } diff --git a/lttng-events.c b/lttng-events.c index 687e8bc1..da1d38e6 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -1120,8 +1120,8 @@ int lttng_session_list_tracker_pids(struct lttng_session *session) ret = PTR_ERR(tracker_pids_list_file); goto file_error; } - if (atomic_long_add_unless(&session->file->f_count, - 1, INT_MAX) == INT_MAX) { + if (!atomic_long_add_unless(&session->file->f_count, 1, LONG_MAX)) { + ret = -EOVERFLOW; goto refcount_error; } ret = lttng_tracker_pids_list_fops.open(NULL, tracker_pids_list_file);