From patchwork Tue Jul 11 14:15:38 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: 13308801 X-Patchwork-Delegate: mhiramat@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33718EB64DD for ; Tue, 11 Jul 2023 14:15:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233327AbjGKOPp (ORCPT ); Tue, 11 Jul 2023 10:15:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233445AbjGKOPo (ORCPT ); Tue, 11 Jul 2023 10:15:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79870B0; Tue, 11 Jul 2023 07:15:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 16C1D6150D; Tue, 11 Jul 2023 14:15:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0848FC433C8; Tue, 11 Jul 2023 14:15:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689084942; bh=B/xbZAcfESero9MbnK8hn07jc1YnxzqHt+73/OKFhoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tsqVZDBrt4sxiMKWtpCFTvByTQZFO7mAdGegliLhzJXs15V7YqWsqgnHerRcec5U+ Q/aaehktA8TSQGy3P2IRj2d9B6EYVTJ+OCKfI/Tfo17m6Rqe1hWpQQW6gLX9r7YOzV VeakEbJVbz9A5ixmsRtkWbHgzaYCL5u/Y7fFK/4vK2ugWUfhC94NjpyxXdz0df++TV 6Zqq6oeZmITh9QUwuYUDk8+gH+gny3tsYjFJqtLbbAFf99Us4d5y94mShmPB1DbFXl ggzQkydSW+OAFgriURtQRzGL9eaRhw2gcBBwwp+58HckLCUKp+XJm+/88Uiegq+3y2 vRhEWB1Io84fA== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: Dan Carpenter , linux-trace-kernel@vger.kernel.org, LKML , Masami Hiramatsu Subject: [PATCH v5 2/5] tracing/probes: Fix not to count error code to total length Date: Tue, 11 Jul 2023 23:15:38 +0900 Message-Id: <168908493827.123124.2175257289106364229.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <168908491977.123124.16583481716284477889.stgit@devnote2> References: <168908491977.123124.16583481716284477889.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org From: Masami Hiramatsu (Google) Fix not to count the error code (which is minus value) to the total used length of array, because it can mess up the return code of process_fetch_insn_bottom(). Also clear the 'ret' value because it will be used for calculating next data_loc entry. Reported-by: Dan Carpenter Closes: https://lore.kernel.org/all/8819b154-2ba1-43c3-98a2-cbde20892023@moroto.mountain/ Fixes: 9b960a38835f ("tracing: probeevent: Unify fetch_insn processing common part") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Steven Rostedt (Google) --- kernel/trace/trace_probe_tmpl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h index 4735c5cb76fa..ed9d57c6b041 100644 --- a/kernel/trace/trace_probe_tmpl.h +++ b/kernel/trace/trace_probe_tmpl.h @@ -204,6 +204,8 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val, array: /* the last stage: Loop on array */ if (code->op == FETCH_OP_LP_ARRAY) { + if (ret < 0) + ret = 0; total += ret; if (++i < code->param) { code = s3;