lttng-abi.c: fix the error check
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · * [email protected] ([email protected]) wrote:
From: "Maxin B. John" <[email protected]>
lttng_syscalls_register()may return-ENOMEMor-EINVAL. So fix the error path to check for negative values inlttng_abi_create_event()andlttng_channel_ioctl().
I don't understand what this is supposed to fix.
The expected return values from lttng_syscalls_register are:
0 -> success-EINVAL -> error-ENOMEM -> error
so whether we check for error with
if (ret)
or
if (ret < 0)
should yield to the exact same result, since we don't expect positive return values.
And for lttng_abi_create_event(), the original code flow is to execute 2 kfree(), and then "return ret", which will return either -EINVAL or -ENOMEM to the caller.
So by adding this return -ENOMEM, you hide the real cause (-EINVAL or -ENOMEM), and you add 2 memory leaks.
Or am I missing something ?
Thanks,
Mathieu
Quoted 36 lines
Signed-off-by Maxin B. John <[email protected]>--- lttng-abi.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)lttng-abi.c +3
-1@@ -648,7 +648,7 @@ int lttng_abi_create_event(struct file *channel_file,if (event_param->name[0 ] !='\0' )return -EINVAL ; ret =lttng_syscalls_register (channel,NULL ); -if (ret) +if (ret <0 ) goto fd_error; event_fd =0 ;break ;@@ -753,6 +753,8 @@ long lttng_channel_ioctl(struct file *file, unsigned int cmd, unsigned long arg)break ; } ret =lttng_abi_create_event (file, uevent_param); +if (ret <0 ) +return -ENOMEM ; old_event_error_free_old_param:kfree (old_uevent_param);Signature · 7 lines
1.7.5.4 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com