[lttng-dev] [PATCH lttng-modules] Fix: build failure on 2.6.36
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Sat Aug 29 17:15:18 EDT 2015
----- On Aug 29, 2015, at 1:03 PM, Michael Jeanson mjeanson at efficios.com wrote:
> Fixes build failure on the 2.6.36 kernel branch which misses the
> vzalloc() function.
>
> Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
> ---
> lttng-events.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/lttng-events.c b/lttng-events.c
> index b49851b..422a2dd 100644
> --- a/lttng-events.c
> +++ b/lttng-events.c
> @@ -133,7 +133,12 @@ struct lttng_session *lttng_session_create(void)
> GFP_KERNEL);
> if (!metadata_cache)
> goto err_free_session;
> +#if LTTNG_KERNEL_RANGE(2,6,36, 2,6,37)
> + metadata_cache->data = vmalloc(METADATA_CACHE_DEFAULT_SIZE);
> + memset(metadata_cache->data, 0, METADATA_CACHE_DEFAULT_SIZE);
You need to test whether vmalloc returned NULL before writing
to it.
Moreover, I'm against putting such preprocessor conditionals
in the code. We should create a wrapper header for vzalloc
implementing lttng_vzalloc instead.
Thanks,
Mathieu
> +#else
> metadata_cache->data = vzalloc(METADATA_CACHE_DEFAULT_SIZE);
> +#endif
> if (!metadata_cache->data)
> goto err_free_cache;
> metadata_cache->cache_alloc = METADATA_CACHE_DEFAULT_SIZE;
> @@ -1531,7 +1536,12 @@ int lttng_metadata_printf(struct lttng_session *session,
> tmp_cache_alloc_size = max_t(unsigned int,
> session->metadata_cache->cache_alloc + len,
> session->metadata_cache->cache_alloc << 1);
> +#if LTTNG_KERNEL_RANGE(2,6,36, 2,6,37)
> + tmp_cache_realloc = vmalloc(tmp_cache_alloc_size);
> + memset(tmp_cache_realloc, 0, tmp_cache_alloc_size);
> +#else
> tmp_cache_realloc = vzalloc(tmp_cache_alloc_size);
> +#endif
> if (!tmp_cache_realloc)
> goto err;
> if (session->metadata_cache->data) {
> --
> 1.9.1
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list