From: Mathieu Desnoyers Date: Tue, 23 Aug 2011 20:12:06 +0000 (-0400) Subject: Add missing error handling X-Git-Tag: v1.9.1~272 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=afdf9825400f1b975a98202a3e9dcbec0a572a56;p=lttng-ust.git Add missing error handling Signed-off-by: Mathieu Desnoyers --- diff --git a/libringbuffer/ring_buffer_backend.c b/libringbuffer/ring_buffer_backend.c index 816c99cb..cac746c2 100644 --- a/libringbuffer/ring_buffer_backend.c +++ b/libringbuffer/ring_buffer_backend.c @@ -278,6 +278,8 @@ int channel_backend_init(struct channel_backend *chanb, struct shm_object *shmobj; shmobj = shm_object_table_append(handle->table, shmsize); + if (!shmobj) + goto end; align_shm(shmobj, __alignof__(struct lib_ring_buffer)); set_shmp(chanb->buf[i].shmp, zalloc_shm(shmobj, sizeof(struct lib_ring_buffer))); buf = shmp(handle, chanb->buf[i].shmp); @@ -294,6 +296,8 @@ int channel_backend_init(struct channel_backend *chanb, struct lib_ring_buffer *buf; shmobj = shm_object_table_append(handle->table, shmsize); + if (!shmobj) + goto end; align_shm(shmobj, __alignof__(struct lib_ring_buffer)); set_shmp(chanb->buf[0].shmp, zalloc_shm(shmobj, sizeof(struct lib_ring_buffer))); buf = shmp(handle, chanb->buf[0].shmp); diff --git a/libringbuffer/shm.c b/libringbuffer/shm.c index e1dd56f9..873e6e87 100644 --- a/libringbuffer/shm.c +++ b/libringbuffer/shm.c @@ -120,7 +120,6 @@ error_fcntl: } } error_pipe: - free(obj); return NULL; } diff --git a/libust/ltt-ring-buffer-client.h b/libust/ltt-ring-buffer-client.h index 697324c7..b3e6f007 100644 --- a/libust/ltt-ring-buffer-client.h +++ b/libust/ltt-ring-buffer-client.h @@ -381,6 +381,8 @@ struct ltt_channel *_channel_create(const char *name, ltt_chan->handle = channel_create(&client_config, name, ltt_chan, buf_addr, subbuf_size, num_subbuf, switch_timer_interval, read_timer_interval); + if (!ltt_chan->handle) + return NULL; ltt_chan->chan = shmp(ltt_chan->handle, ltt_chan->handle->chan); return ltt_chan; }