Commit d9f5f335 authored by Max Filippov's avatar Max Filippov Committed by Stefan Bader

xtensa: fix return_address

BugLink: https://bugs.launchpad.net/bugs/1828420

commit ada770b1 upstream.

return_address returns the address that is one level higher in the call
stack than requested in its argument, because level 0 corresponds to its
caller's return address. Use requested level as the number of stack
frames to skip.

This fixes the address reported by might_sleep and friends.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 124de5dd
...@@ -272,10 +272,14 @@ static int return_address_cb(struct stackframe *frame, void *data) ...@@ -272,10 +272,14 @@ static int return_address_cb(struct stackframe *frame, void *data)
return 1; return 1;
} }
/*
* level == 0 is for the return address from the caller of this function,
* not from this function itself.
*/
unsigned long return_address(unsigned level) unsigned long return_address(unsigned level)
{ {
struct return_addr_data r = { struct return_addr_data r = {
.skip = level + 1, .skip = level,
}; };
walk_stackframe(stack_pointer(NULL), return_address_cb, &r); walk_stackframe(stack_pointer(NULL), return_address_cb, &r);
return r.addr; return r.addr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment