Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp18037rwn; Wed, 7 Sep 2022 19:01:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR63E/Gi0o03mIhmtd1P4zyJ4vGpNtnLgHJFYiG80k4mCm+CSpNXY1tJ7UaKQNADkLzGsDDk X-Received: by 2002:a17:902:d14c:b0:176:acfb:a84c with SMTP id t12-20020a170902d14c00b00176acfba84cmr6897692plt.159.1662602515794; Wed, 07 Sep 2022 19:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662602515; cv=none; d=google.com; s=arc-20160816; b=rb5aShyaJXxvw40pwArgdyM/FZnZ0ZlyUSaibvaRM+ajbpBulk/OCGioYTggk9+HYI oo0KEWFzwJpvQSrZ3R10jUyRvn1Pkzzq4Qoo7UntXmBXzI0vdbX4v82+sGohcTiwf9Ur fk0GzGs4sLA24ve7WEd8xdcarDYzuvg141o4OI4o7EyJ/fy7zk11VU4GqtLazep/HZ8i n7DonVu7F/Bc9xJM1t0npdZeHJZ2ckpgv9e5XCsW3UuIqMJqKXqcoIsoPbkVzVsUtIiu tOSdXA3uyQI7yk3x7nbqc4kBvzcSW4FLNtM7CTYRyfxC3vBERTVenfQ2ZSv+6ftSW/N3 P1Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=ol2M8dTlD4I+O60SnEKOVxy73qWPvPb5rrf9V1OWIFw=; b=v4hYUOlNJPHMcOo/pAzumn+3mx7ZJvsESqtYNnG7uCyisyegoQ1wf9LQhOZMxfaOjW MeJoTbarfsjYjxMVa1YgTTxaHOBYCD+crZDu9+RmuN3h/45thSsigPiIJz1v0gPjym9c hyLU02lWoshRrGiKOzZpK1iMTcSGvpReW/1rxmMJTJe+H+K8Z04Vh2CqmQVXLRAoYobh 1mXni78JbodNCdEFdDIOCPxyBMPenoc2m3WkEDnPPQtBIf6Nwc7hU0CPtpR06wPKxBtI VJ98DRldTguKd3lTdWwZ967uTzESc9Pg9y8etPpay/Sea0Oleo8s9u+f8VVe7U/lIllY BhAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hk16-20020a17090b225000b002000fca8d77si967968pjb.138.2022.09.07.19.01.41; Wed, 07 Sep 2022 19:01:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbiIHBj3 (ORCPT + 99 others); Wed, 7 Sep 2022 21:39:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbiIHBj2 (ORCPT ); Wed, 7 Sep 2022 21:39:28 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E9351219D for ; Wed, 7 Sep 2022 18:39:22 -0700 (PDT) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxbWvERxljTg8UAA--.34410S2; Thu, 08 Sep 2022 09:39:16 +0800 (CST) From: Tiezhu Yang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Masami Hiramatsu Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] riscv: kprobes: Free instruction in arch_remove_kprobe() Date: Thu, 8 Sep 2022 09:39:16 +0800 Message-Id: <1662601156-25802-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf8CxbWvERxljTg8UAA--.34410S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Jw15XFy7Xry5tFW8tryDAwb_yoW3Awc_C3 4xtryrKr4YkFW8uFy7Kr4rtrZxC34ftFn5Wr12gry5Kry7JFy5KanYgr1UW3s5W395tF9x JwnxZrZ3XF47ZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb28YjsxI4VWxJwAYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I 6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM2 8CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0 cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4 vEx4A2jsIEc7CjxVAFwI0_Cr1j6rxdM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVAC Y4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJV W8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc2xSY4AK67AK6w4l42xK 82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGw C20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48J MIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMI IF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E 87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07jnZ2-UUUUU= X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call free_insn_slot() to free instruction in arch_remove_kprobe() as other arches do. Signed-off-by: Tiezhu Yang --- arch/riscv/kernel/probes/kprobes.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c index e6e950b..f12eb1f 100644 --- a/arch/riscv/kernel/probes/kprobes.c +++ b/arch/riscv/kernel/probes/kprobes.c @@ -110,6 +110,10 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) void __kprobes arch_remove_kprobe(struct kprobe *p) { + if (p->ainsn.api.insn) { + free_insn_slot(p->ainsn.api.insn, 0); + p->ainsn.api.insn = NULL; + } } static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) -- 2.1.0