From patchwork Sun Apr 9 02:28:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 81295 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1168843vqo; Sat, 8 Apr 2023 20:02:48 -0700 (PDT) X-Google-Smtp-Source: AKy350ZQX03WhJSbTQdSgkQ7Rpl+h4LDer30ywqKT9eSOI4y+wjbXijJiWnflrcFpbcBQ6gk1cDG X-Received: by 2002:a17:902:e30c:b0:19c:65bd:d44b with SMTP id q12-20020a170902e30c00b0019c65bdd44bmr3563838plc.60.1681009368392; Sat, 08 Apr 2023 20:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681009368; cv=none; d=google.com; s=arc-20160816; b=Gv/epH0Jnt3G+jkS4sL7XZyLBvbXmG7eUaNY+924FjwB8lq4jQcz9LtXUAZsvo3tg+ 41RFRP6OeZA3slU8YN8rjWDKCo6yaAUb283lfb0FhDrOkVFAdh8bPst9zuZI8vLO2j5S hiv2PXNlFppxHCpTqcgE1wpEG4P8OPw/RSEMZ7U547iSavh9l9mriG2R5E/jpCW/wpTS D4ge5DrP+ksOnLA+JSRvAlpSGPCt7U+X4NdOnQzU3nIyiCTrWX7l3PXteqp5aMqfuCN9 hTu23BKlKHW0K27MBYnWg3wgB2hMnAqXuQqA1nw/9xzaHfmBn8Z+Iz4PFtZRQEDah/cv qD1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:subject:cc:to:from:dkim-signature; bh=8grpFhnKQOX+Jy3Bj1WdvPed0H8JixxXMVDyquAhlrc=; b=TCMEBeHJzTssPMrCMKEYZMImm5pvI/6J4Wo3xCpcqR0EUdOu5p9DKDysNzVl3kDooB 3a5Bww80RlqZmm4C9NYm8CzQbV45XPqw7EwPyIszAXvcIrDKVI97h5HlaqHUnhGoMdH1 ZgQRNG7idOOXBv3zLq4EIQPCXnxbXSGZfjTDWkN44mWVFXLCWoMqVA/Oo1R1K3YFUIgr ljyW9GPzqGIZnEIoyYubHw5lUZh4wQF3/W3S7brrBh0uEdXbV3/dhII+sZnkgzFnkrM0 QfIpejvm/9e86G1WT4G94Djzltx/vecbvjqeHWJYM0QtTuhpMz+ekeQT4jS1fmcbb5Gg cA1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YL6UoNE4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g193-20020a636bca000000b00518b08a92f4si1580855pgc.498.2023.04.08.20.02.27; Sat, 08 Apr 2023 20:02:48 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YL6UoNE4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229523AbjDIC2j (ORCPT + 99 others); Sat, 8 Apr 2023 22:28:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjDIC2i (ORCPT ); Sat, 8 Apr 2023 22:28:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D86559EE; Sat, 8 Apr 2023 19:28:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CBCA960B76; Sun, 9 Apr 2023 02:28:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA72AC433EF; Sun, 9 Apr 2023 02:28:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681007316; bh=cVM9AQdC8fERYzKAP4b8qgin6kb00dHQoiudcmM67Kc=; h=From:To:Cc:Subject:Date:From; b=YL6UoNE4UOqxWO0btsl854aWVZUbhPDqousyhhFcRUd3gvUe2MYZTM1THXsyYnk6m QaRUNoUa3scudLcmgJVehdlZSvAaz+TyZ+totE4haQ+VGoEp+Hw5NmcCzjwUdyqpZo Bqlp0FJ/sjOSUuGgrQcQKQ7h64hAUX5glssIWDVigrtlJs67rm8t7/vBAujOd0+XAT bM3fvFy/JbCkceEjJ+g/qvUbiuJkfPdisBqWBWVjc3yrFK0/AJljic1DUhUM+pvw/5 nOll+Zeqp/GdotEfUGhFGabZ2xRjrnFEcuXwoOwIUTtMkJjZZEGVBhWWSy+Xl3TDjl kF/7lKcPl0Y/w== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: Dan Carpenter , Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH] tracing: fprobe: Initialize ret valiable to fix smatch error Date: Sun, 9 Apr 2023 11:28:31 +0900 Message-Id: <168100731160.79534.374827110083836722.stgit@devnote2> X-Mailer: git-send-email 2.25.1 User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762666079322803778?= X-GMAIL-MSGID: =?utf-8?q?1762666079322803778?= From: Masami Hiramatsu (Google) The commit 39d954200bf6 ("fprobe: Skip exit_handler if entry_handler returns !0") introduced a hidden dependency of 'ret' local variable in the fprobe_handler(), Smatch warns the `ret` can be accessed without initialization. kernel/trace/fprobe.c:59 fprobe_handler() error: uninitialized symbol 'ret'. kernel/trace/fprobe.c 49 fpr->entry_ip = ip; 50 if (fp->entry_data_size) 51 entry_data = fpr->data; 52 } 53 54 if (fp->entry_handler) 55 ret = fp->entry_handler(fp, ip, ftrace_get_regs(fregs), entry_data); ret is only initialized if there is an ->entry_handler 56 57 /* If entry_handler returns !0, nmissed is not counted. */ 58 if (rh) { rh is only true if there is an ->exit_handler. Presumably if you have and ->exit_handler that means you also have a ->entry_handler but Smatch is not smart enough to figure it out. --> 59 if (ret) ^^^ Warning here. 60 rethook_recycle(rh); 61 else 62 rethook_hook(rh, ftrace_get_regs(fregs), true); 63 } 64 out: 65 ftrace_test_recursion_unlock(bit); 66 } Reported-by: Dan Carpenter Link: https://lore.kernel.org/all/85429a5c-a4b9-499e-b6c0-cbd313291c49@kili.mountain Fixes: 39d954200bf6 ("fprobe: Skip exit_handler if entry_handler returns !0") Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c index 9abb3905bc8e..293184227394 100644 --- a/kernel/trace/fprobe.c +++ b/kernel/trace/fprobe.c @@ -27,7 +27,7 @@ static void fprobe_handler(unsigned long ip, unsigned long parent_ip, struct rethook_node *rh = NULL; struct fprobe *fp; void *entry_data = NULL; - int bit, ret; + int bit, ret = 0; fp = container_of(ops, struct fprobe, ops); if (fprobe_disabled(fp))