From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4662535949 for ; Thu, 19 Mar 2026 14:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773929212; cv=none; b=oy60e3tkP1izC2IHhju8+qcROImoJFAjRzxg0qdVHR4DDg3/cylhZk7TVyx5ynguDpFnng2iFPUpHiY9k6ITGnZ336uUN3PtoDMMk4uTeVEThEVVHDYuc+GJrhGrrHL5UZu41LQ1mSbK3EPKKKyoDedbWiYjSUkLKdBlkd/sv+U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773929212; c=relaxed/simple; bh=1oPEVfHnlm0vBT9kFitDXJh5k+Y0zGftjiCCwWDOgog=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cv3sC1TgUj0iAUbbUod6/+3Qlxs2WXbYZA/nJQXOc6/QUZSZ4qF9fh0hv92rxCIzXW11ZSXYUifE1SdQT6DmPMWLaLM3w+1Dbwq9SXZSVTVlFcOZpZIyZlPHaQrK78BmIOVk0a6B8XcBZvPuRl6ZUDSXhmL7gbHLFwx9fKt9yt8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s0mbfeQ4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="s0mbfeQ4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76519C19424; Thu, 19 Mar 2026 14:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773929211; bh=1oPEVfHnlm0vBT9kFitDXJh5k+Y0zGftjiCCwWDOgog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s0mbfeQ4NjWtUxx39qMlRov0EQfSaOPlV8Ar1774TigxsBpWd1Ku4EDGcbbLvUsnF S8GqUgtPa7wdsle9/4wMHTDev6/N4v+rj2GY47z4dr5N1zMifBsHxzee/lNHvm4xQy iJ+vStcj/DCMxuKgJH53QDksqnzULyfiCvDpu0NbfYQDSncefEVQrJJO3elShIPmnq Nwce0zAedKQFMbfRLGwqYmMt/Z+aGytz2zMsctsFHk3OOEuZKeheLBdGXDlvw/acdq wCtBlAEGW+ek/GlLMz3IamdqRHC5nvWjrYp7QeR7Re1GZH1RPygOqB6KmDAXuzr858 VfoO/ISJqm/5g== From: Sasha Levin To: stable@vger.kernel.org Cc: "Masami Hiramatsu (Google)" , Sasha Levin Subject: [PATCH 6.1.y 1/2] kprobes: Remove unneeded goto Date: Thu, 19 Mar 2026 10:06:47 -0400 Message-ID: <20260319140648.2491064-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026031702-gesture-tragedy-2d56@gregkh> References: <2026031702-gesture-tragedy-2d56@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Masami Hiramatsu (Google)" [ Upstream commit 5e5b8b49335971b68b54afeb0e7ded004945af07 ] Remove unneeded gotos. Since the labels referred by these gotos have only one reference for each, we can replace those gotos with the referred code. Link: https://lore.kernel.org/all/173371211203.480397.13988907319659165160.stgit@devnote2/ Signed-off-by: Masami Hiramatsu (Google) Stable-dep-of: 5ef268cb7a0a ("kprobes: Remove unneeded warnings from __arm_kprobe_ftrace()") Signed-off-by: Sasha Levin --- kernel/kprobes.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 4c4fc4d309b8b..c2ca192b97aea 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1082,20 +1082,18 @@ static int __arm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops, if (*cnt == 0) { ret = register_ftrace_function(ops); - if (WARN(ret < 0, "Failed to register kprobe-ftrace (error %d)\n", ret)) - goto err_ftrace; + if (WARN(ret < 0, "Failed to register kprobe-ftrace (error %d)\n", ret)) { + /* + * At this point, sinec ops is not registered, we should be sefe from + * registering empty filter. + */ + ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0); + return ret; + } } (*cnt)++; return ret; - -err_ftrace: - /* - * At this point, sinec ops is not registered, we should be sefe from - * registering empty filter. - */ - ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0); - return ret; } static int arm_kprobe_ftrace(struct kprobe *p) @@ -1447,7 +1445,7 @@ _kprobe_addr(kprobe_opcode_t *addr, const char *symbol_name, unsigned long offset, bool *on_func_entry) { if ((symbol_name && addr) || (!symbol_name && !addr)) - goto invalid; + return ERR_PTR(-EINVAL); if (symbol_name) { /* @@ -1477,11 +1475,10 @@ _kprobe_addr(kprobe_opcode_t *addr, const char *symbol_name, * at the start of the function. */ addr = arch_adjust_kprobe_addr((unsigned long)addr, offset, on_func_entry); - if (addr) - return addr; + if (!addr) + return ERR_PTR(-EINVAL); -invalid: - return ERR_PTR(-EINVAL); + return addr; } static kprobe_opcode_t *kprobe_addr(struct kprobe *p) @@ -1504,15 +1501,15 @@ static struct kprobe *__get_valid_kprobe(struct kprobe *p) if (unlikely(!ap)) return NULL; - if (p != ap) { - list_for_each_entry(list_p, &ap->list, list) - if (list_p == p) - /* kprobe p is a valid probe */ - goto valid; - return NULL; - } -valid: - return ap; + if (p == ap) + return ap; + + list_for_each_entry(list_p, &ap->list, list) + if (list_p == p) + /* kprobe p is a valid probe */ + return ap; + + return NULL; } /* -- 2.51.0