diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index 27bafc1e271ee7e444e889cc9bff4dc4d6f40d14..90d3e0bf0302dbe39a8ea4913bddab3cfacfb6a5 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -206,7 +206,7 @@ int stack_trace_save_tsk_reliable(struct task_struct *tsk, unsigned long *store,
 
 	ret = arch_stack_walk_reliable(consume_entry, &c, tsk);
 	put_task_stack(tsk);
-	return ret;
+	return ret ? ret : c.len;
 }
 #endif