[PATCH] alpha: Fix condition 'i>40' is always false

liujing posted 1 patch 1 year ago
[PATCH] alpha: Fix condition 'i>40' is always false
Posted by liujing 1 year ago
The i variable is used to count the number of stack frames printed,
but it is initialized to 0 only at the beginning of the loop, and
is not increased later in the loop. Therefore, the value of i is
always 0, resulting in the condition if (i > 40) never being true.

To ensure that i counts correctly, you need to increase the value
of i each time the stack frame is successfully printed.

Signed-off-by: liujing <liujing@cmss.chinamobile.com>

diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
index 6afae65e9a8b..65c44756f949 100644
--- a/arch/alpha/kernel/traps.c
+++ b/arch/alpha/kernel/traps.c
@@ -100,6 +100,7 @@ dik_show_trace(unsigned long *sp, const char *loglvl)
 		if (!is_kernel_text(tmp))
 			continue;
 		printk("%s[<%lx>] %pSR\n", loglvl, tmp, (void *)tmp);
+		i++;
 		if (i > 40) {
 			printk("%s ...", loglvl);
 			break;
-- 
2.27.0
Re: [PATCH] alpha: Fix condition 'i>40' is always false
Posted by Markus Elfring 1 year ago
…
> To ensure that i counts correctly, you need to increase the value
> of i each time the stack frame is successfully printed.

How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.13-rc1#n145

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.13-rc1#n94


> Signed-off-by: liujing <liujing@cmss.chinamobile.com>

Under which circumstances may a personal name deviate from an email identifier?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.13-rc1#n436

Regards,
Markus