From: Mathieu Desnoyers Date: Thu, 26 Jun 2014 17:50:15 +0000 (-0400) Subject: Fix: statedump handle oom case, handle errors X-Git-Tag: v2.4.2~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2f471d074818375e985ca0df03741a609d0750ba;p=lttng-modules.git Fix: statedump handle oom case, handle errors lttng_enumerate_file_descriptors should check the pointer returned by __get_free_page() (check if NULL). do_lttng_statedump should check the sub-function return values. For lttng_enumerate_block_devices(), we allow -ENOSYS to continue (if not implemented). Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-statedump-impl.c b/lttng-statedump-impl.c index 40eab8e5..78c07adc 100644 --- a/lttng-statedump-impl.c +++ b/lttng-statedump-impl.c @@ -188,7 +188,11 @@ static int lttng_enumerate_file_descriptors(struct lttng_session *session) { struct task_struct *p; - char *tmp = (char *) __get_free_page(GFP_KERNEL); + char *tmp; + + tmp = (char *) __get_free_page(GFP_KERNEL); + if (!tmp) + return -ENOMEM; /* Enumerate active file descriptors */ rcu_read_lock(); @@ -254,7 +258,7 @@ int lttng_enumerate_vm_maps(struct lttng_session *session) #endif static -void lttng_list_interrupts(struct lttng_session *session) +int lttng_list_interrupts(struct lttng_session *session) { unsigned int irq; unsigned long flags = 0; @@ -276,12 +280,14 @@ void lttng_list_interrupts(struct lttng_session *session) wrapper_desc_spin_unlock(&desc->lock); local_irq_restore(flags); } + return 0; #undef irq_to_desc } #else static inline -void lttng_list_interrupts(struct lttng_session *session) +int lttng_list_interrupts(struct lttng_session *session) { + return 0; } #endif @@ -382,14 +388,27 @@ void lttng_statedump_work_func(struct work_struct *work) static int do_lttng_statedump(struct lttng_session *session) { - int cpu; + int cpu, ret; trace_lttng_statedump_start(session); - lttng_enumerate_process_states(session); - lttng_enumerate_file_descriptors(session); - /* FIXME lttng_enumerate_vm_maps(session); */ - lttng_list_interrupts(session); - lttng_enumerate_network_ip_interface(session); + ret = lttng_enumerate_process_states(session); + if (ret) + return ret; + ret = lttng_enumerate_file_descriptors(session); + if (ret) + return ret; + /* + * FIXME + * ret = lttng_enumerate_vm_maps(session); + * if (ret) + * return ret; + */ + ret = lttng_list_interrupts(session); + if (ret) + return ret; + ret = lttng_enumerate_network_ip_interface(session); + if (ret) + return ret; /* TODO lttng_dump_idt_table(session); */ /* TODO lttng_dump_softirq_vec(session); */