Fix: statedump handle oom case, handle errors
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 26 Jun 2014 17:50:15 +0000 (13:50 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 26 Jun 2014 18:56:07 +0000 (14:56 -0400)
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 <mathieu.desnoyers@efficios.com>
lttng-statedump-impl.c

index 40eab8e54a4c0fa3488108bb120edcf44cb45985..78c07adc6f354ea1ab3d98366f78d0787e75d22a 100644 (file)
@@ -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); */
This page took 0.027051 seconds and 4 git commands to generate.