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 17:50:15 +0000 (13:50 -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 c8ac2d12750d210a11a9c375d2cf0f0aed39e189..d0e641a97ca70452508ccf618ebf9c594b67cb5b 100644 (file)
@@ -259,7 +259,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();
@@ -325,7 +329,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;
@@ -347,12 +351,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
 
@@ -453,15 +459,35 @@ 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);
-       lttng_enumerate_block_devices(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;
+       ret = lttng_enumerate_block_devices(session);
+       switch (ret) {
+       case -ENOSYS:
+               printk(KERN_WARNING "LTTng: block device enumeration is not supported by kernel\n");
+               break;
+       default:
+               return ret;
+       }
 
        /* TODO lttng_dump_idt_table(session); */
        /* TODO lttng_dump_softirq_vec(session); */
This page took 0.027818 seconds and 4 git commands to generate.