Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 57c24b2

Browse files
Huang Shijietorvalds
authored andcommitted
samples/kretprobe: fix the wrong type
The regs_return_value() returns "unsigned long" or "long" value. But the retval is int type now, it may cause overflow, the log may becomes: [ 2911.078869] do_brk returned -2003877888 and took 4620 ns to execute This patch converts the retval to "unsigned long" type, and fixes the overflow issue. Link: http://lkml.kernel.org/r/1464143083-3877-4-git-send-email-shijie.huang@arm.com Signed-off-by: Huang Shijie <shijie.huang@arm.com> Cc: Petr Mladek <pmladek@suse.com> Cc: Steve Capper <steve.capper@arm.com> Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6134131 commit 57c24b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

samples/kprobes/kretprobe_example.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ static int entry_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
5555
*/
5656
static int ret_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
5757
{
58-
int retval = regs_return_value(regs);
58+
unsigned long retval = regs_return_value(regs);
5959
struct my_data *data = (struct my_data *)ri->data;
6060
s64 delta;
6161
ktime_t now;
6262

6363
now = ktime_get();
6464
delta = ktime_to_ns(ktime_sub(now, data->entry_stamp));
65-
pr_info("%s returned %d and took %lld ns to execute\n",
65+
pr_info("%s returned %lu and took %lld ns to execute\n",
6666
func_name, retval, (long long)delta);
6767
return 0;
6868
}

0 commit comments

Comments
 (0)