Skip to content

Commit 57c24b2

Browse files
Huang Shijietorvalds
Huang Shijie
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/[email protected] Signed-off-by: Huang Shijie <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Steve Capper <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Anil S Keshavamurthy <[email protected]> Cc: Masami Hiramatsu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
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

+2-2
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)