Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4140371pxb; Sun, 24 Oct 2021 21:07:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEe6aUO8Syx0hX1BNzbxAcOVb/Qun05Taz7AJ24MQRfbrrbOg/++KDH4gro1jND4KXLG5e X-Received: by 2002:a50:934f:: with SMTP id n15mr14827149eda.391.1635134838700; Sun, 24 Oct 2021 21:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635134838; cv=none; d=google.com; s=arc-20160816; b=iHI47jrUqqPrmEuKtjwDS8UB4B7CEJFq/ZZ9gTBqoVKv9lfe+XCKHWGuTwd9JkxbYb lSJMMIB3/d+Jcnui1I+I40HlooxKt8dEtnnW8TjdVjsU6k0h/k1oUTE38LknzZskgi9c yGztdlHyhBsKMh+ILNoSU2L1l+mL7wjX2MuSN1Wg2Q41Ku4HcRyJnQow2WH9lDEBjzIB rEE9e79lT116GWM1l7sG/MPSwolqC2Ra3bLk+9OgQPfQvFZribbZhcpAFnZ0ITupMmhA EdTTvKYZC8rjutiC9Gk6qxPE1AuxT5XQyPJ+OfNJqREftwqMEz39Ptt9zqZqtbt+X77E a0hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=sTMFspsaNqrUxT3vgmMopKy+Ma4yhmrNYv/qTfb1EZo=; b=jPGw+eUOD2W3vPHlbJ3X8Ts7R1SH5Sgm3Yzp2unqmkfG9rKkzETROag6hBzfO4fsuV ugUh7PZkmBqynU6njI58GetGOhsh81h6wzhmp1xg88QouGrjb64GMMUNrKrfTMpCWGyW AC5afWweJ69qha3q98Iaga9DWeK7S+nwH9KdReeqjGJ3wZTcWrp3dureK/T+IfmTDbEJ 1nNsUBi9QkeIFqRFd/tWKhfRLk41aWVrHi34OhTPWkSpwy8X4Ql5PKaqXdX3/dmBPbXN cwi2jB0o8kWeJVMnLUuAIhRMf3w9iWqgdO/r1e5oXfXt76xSU+c9CjgkE4WtvtUXPf3/ njVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si18462954edm.372.2021.10.24.21.06.54; Sun, 24 Oct 2021 21:07:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232377AbhJYDdk (ORCPT + 99 others); Sun, 24 Oct 2021 23:33:40 -0400 Received: from mail.loongson.cn ([114.242.206.163]:53840 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232198AbhJYDdg (ORCPT ); Sun, 24 Oct 2021 23:33:36 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9CxhOb1JHZhrpgfAA--.56276S3; Mon, 25 Oct 2021 11:31:03 +0800 (CST) From: Tiezhu Yang To: naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org, corbet@lwn.net Cc: ananth@in.ibm.com, akpm@linux-foundation.org, randy.dunlap@oracle.com, mathieu.desnoyers@polymtl.ca, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] samples/kretprobes: Fix return value if register_kretprobe() failed Date: Mon, 25 Oct 2021 11:30:57 +0800 Message-Id: <1635132660-5038-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1635132660-5038-1-git-send-email-yangtiezhu@loongson.cn> References: <1635132660-5038-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9CxhOb1JHZhrpgfAA--.56276S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Jr1kCr4DGFWDtFy3GFyUZFb_yoW8JF1kpF 4q934Ykr9Ygr43AFZ8X34rCryFg34kWF47Jr4rGw17t3ZIvw1DXrWIgayjvanxurZ0qr13 ta1UXr90va47AFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPvb7Iv0xC_Cr1lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI 8067AKxVWUGwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF 64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcV CY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2 jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4 CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE14v26r1j6r4UMcvj eVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxw CY02Avz4vE14v_Gr4l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2Iq xVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r 1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY 6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67 AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuY vjxUsUDGDUUUU X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the actual return value instead of always -1 if register_kretprobe() failed. E.g. without this patch: # insmod samples/kprobes/kretprobe_example.ko func=no_such_func insmod: ERROR: could not insert module samples/kprobes/kretprobe_example.ko: Operation not permitted With this patch: # insmod samples/kprobes/kretprobe_example.ko func=no_such_func insmod: ERROR: could not insert module samples/kprobes/kretprobe_example.ko: Unknown symbol in module Fixes: 804defea1c02 ("Kprobes: move kprobe examples to samples/") Signed-off-by: Tiezhu Yang --- samples/kprobes/kretprobe_example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/kprobes/kretprobe_example.c b/samples/kprobes/kretprobe_example.c index 5dc1bf3..228321e 100644 --- a/samples/kprobes/kretprobe_example.c +++ b/samples/kprobes/kretprobe_example.c @@ -86,7 +86,7 @@ static int __init kretprobe_init(void) ret = register_kretprobe(&my_kretprobe); if (ret < 0) { pr_err("register_kretprobe failed, returned %d\n", ret); - return -1; + return ret; } pr_info("Planted return probe at %s: %p\n", my_kretprobe.kp.symbol_name, my_kretprobe.kp.addr); -- 2.1.0