projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: consumer_allocate_stream error handling
[lttng-tools.git]
/
src
/
common
/
consumer.c
diff --git
a/src/common/consumer.c
b/src/common/consumer.c
index f4eaf705f0b811230d0a9bb1f2f74458c7f7e6d0..a9e4dee661b1d1ba13da01a2db4d74ee16f68e8e 100644
(file)
--- a/
src/common/consumer.c
+++ b/
src/common/consumer.c
@@
-345,7
+345,8
@@
struct lttng_consumer_stream *consumer_allocate_stream(
uid_t uid,
gid_t gid,
int net_index,
uid_t uid,
gid_t gid,
int net_index,
- int metadata_flag)
+ int metadata_flag,
+ int *alloc_ret)
{
struct lttng_consumer_stream *stream;
int ret;
{
struct lttng_consumer_stream *stream;
int ret;
@@
-353,12
+354,13
@@
struct lttng_consumer_stream *consumer_allocate_stream(
stream = zmalloc(sizeof(*stream));
if (stream == NULL) {
perror("malloc struct lttng_consumer_stream");
stream = zmalloc(sizeof(*stream));
if (stream == NULL) {
perror("malloc struct lttng_consumer_stream");
- goto end;
+ *alloc_ret = -ENOMEM;
+ return NULL;
}
stream->chan = consumer_find_channel(channel_key);
if (!stream->chan) {
}
stream->chan = consumer_find_channel(channel_key);
if (!stream->chan) {
-
perror("Unable to find channel key")
;
- goto e
nd
;
+
*alloc_ret = -ENOENT
;
+ goto e
rror
;
}
stream->chan->refcount++;
stream->key = stream_key;
}
stream->chan->refcount++;
stream->key = stream_key;
@@
-387,14
+389,14
@@
struct lttng_consumer_stream *consumer_allocate_stream(
stream->cpu = stream->chan->cpucount++;
ret = lttng_ustconsumer_allocate_stream(stream);
if (ret) {
stream->cpu = stream->chan->cpucount++;
ret = lttng_ustconsumer_allocate_stream(stream);
if (ret) {
-
free(stream)
;
-
return NULL
;
+
*alloc_ret = -EINVAL
;
+
goto error
;
}
break;
default:
ERR("Unknown consumer_data type");
}
break;
default:
ERR("Unknown consumer_data type");
-
assert(0)
;
- goto e
nd
;
+
*alloc_ret = -EINVAL
;
+ goto e
rror
;
}
/*
}
/*
@@
-413,9
+415,11
@@
struct lttng_consumer_stream *consumer_allocate_stream(
stream->shm_fd, stream->wait_fd,
(unsigned long long) stream->mmap_len, stream->out_fd,
stream->net_seq_idx);
stream->shm_fd, stream->wait_fd,
(unsigned long long) stream->mmap_len, stream->out_fd,
stream->net_seq_idx);
-
-end:
return stream;
return stream;
+
+error:
+ free(stream);
+ return NULL;
}
/*
}
/*
This page took
0.028539 seconds
and
4
git commands to generate.