From patchwork Fri Jan 26 00:42:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 192341 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp359747dyb; Thu, 25 Jan 2024 16:49:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkGMlSD/jkqbdkGZVm+zvWdIz6NWARwXfopZjwvuvpqIkDyPJ3eWlCnDMEj1iGX2j2f63Q X-Received: by 2002:a17:902:e74e:b0:1d4:208e:a8a0 with SMTP id p14-20020a170902e74e00b001d4208ea8a0mr694992plf.71.1706230176488; Thu, 25 Jan 2024 16:49:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706230176; cv=pass; d=google.com; s=arc-20160816; b=S+bCosRF+5Q9UDkezpfTs79NjiWrubZUD26q/I7DYnTF9g6PwOT5hEVoURyGXrSROx +J6esCz07tlnhsEqml9mpETb5dKpSgCdJUKtjz12C9ewvFPXusKTOyC2+rfpFMqdTaUm MkdWPZf3KSfNhHBwaFeaJWHpTIYP8E+ydwM8+gFukmZVNkZ1h0f6nEDXFtT7Wmp5YJmi x8ZFObJHTmDOVEoAtDI2bXiiQxvmm0PVfCPtc1h58SKC3BVrW9gNJiLkHcYf3yHrzNIy e5wEsRpdSrRwBzjFQhT6ESxUyxvB2OPHlILxrbd4TrxN9NouE4PISYkXsFPsabWknrSs kMQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=VdmCg96RcEAC/bbiW27t+JsK35ap0Tiuqfi81vSU4CY=; fh=qVncCFOldWwKLBsWqiqguqra+Q3XMUFxUMc9SsPYUrc=; b=MgcceTzCfbY+20H17El5rp3M8yPrsCYuYhp4Lt4a9n+wdjzudIFTdigNsMnI2mvu+a MkfEUPh4Sjsp9SdpG44JD1khOgwiuGCYdSW33IfHfgqmNVdyu9LiGFT3TtuTCXdmQJCF ohNjzNh3bNMh9QJTu/w+ShzvJUQ/3sMyjEZN8zGKEa6gmmm0NbF1AhiCvn9xLLfieaeB Y26YhlhcRnqE2yUq3GuwC5PUTzJBsu8D7vlPRqNE1VWNBSqdwtZtk4hwvZYWiewfR6vc eDSJoVCOZnACD4EItTT4m7ouzj+4XPAGI+Jd7JFdcJLZDlyubgw3+mwXcDCPHT18gzKZ Lj5Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b+V9Fdzt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-39465-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39465-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m3-20020a170902f20300b001d76ae4c930si155131plc.110.2024.01.25.16.49.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 16:49:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39465-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b+V9Fdzt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-39465-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39465-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 82211B22C73 for ; Fri, 26 Jan 2024 00:43:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E3F117E9; Fri, 26 Jan 2024 00:43:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b+V9Fdzt" 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 75021362; Fri, 26 Jan 2024 00:43:02 +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=1706229782; cv=none; b=ZTuoZnshAkLyc1TVZYERVRz+/eYSBcBjMsuF5iUMeM0VT6695HMdouk/4DRIVbFCeBxZg8S0cpjpWQsPz9M00MDx8Pb5n9RiU0thsPyHCUWKlbHUJXbCX/T4l+lypDroWRdz/hRrsfidUFLsGWsEu6ZxL42F7YPszeDsZv3edak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706229782; c=relaxed/simple; bh=X9L0utqCp4JboXfTZ3Ic0wfzuMXKK/zwKNw+VR/crP4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=RxWkbgw3oWdCvnS5NgxVQW5g7wdPbHa6wZB7qkqkWYHTGBZ7HmA7b6xqZrHB8CNqx8Yez2MyTyAKOBWntTwJwg4gVha6938ub5GThaWBs+oNzHR0LM8rt2HAvFWN0R2asd5C0d+YXzeSZ2ffFjeOyUxCPhIRxj3PDgQQ8SL+GnY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b+V9Fdzt; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69C1AC433F1; Fri, 26 Jan 2024 00:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706229781; bh=X9L0utqCp4JboXfTZ3Ic0wfzuMXKK/zwKNw+VR/crP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b+V9FdztrTPUZ5L6Gp2+UwD7KFnvs6cAP/SqYJXwzvCHx5MtI+LwSV89qw9cMgEhl 425QTVhmSovIXA1wcSuBJjB/Ns04JIqqCB9JoV419y8WZeojY1tXLlyJ5ULeiUVnJi 5qia9THO0WJgjkOJgiNNLg9sB90T9ZUg4+CjWpIriiwA+7fq27AnFUXC5tImK/dqQ3 1+cYprcMbxln+O0Jlwoa49Nmm4UKe1jwIr1CaD/pfmYX0hc4QYOdNElJe7gJY2IXed BWJpK50Vct5D3V8N4gaR+q/bpmd1kKYNIXnhlqfmCJn7uxuFC0kga1ytPDHBAp9/sd zOjXL8Fibng9g== From: "Masami Hiramatsu (Google)" To: Vincent Donnefort Cc: Masami Hiramatsu , rostedt@goodmis.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, kernel-team@android.com Subject: [PATCH] tracing/trigger: Fix to return error if failed to alloc snapshot Date: Fri, 26 Jan 2024 09:42:58 +0900 Message-Id: <170622977792.270660.2789298642759362200.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789112013578717478 X-GMAIL-MSGID: 1789112013578717478 From: Masami Hiramatsu (Google) Fix register_snapshot_trigger() to return error code if it failed to allocate a snapshot instead of 0 (success). Unless that, it will register snapshot trigger without an error. Fixes: 0bbe7f719985 ("tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/trace_events_trigger.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c index 46439e3bcec4..b33c3861fbbb 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -1470,8 +1470,10 @@ register_snapshot_trigger(char *glob, struct event_trigger_data *data, struct trace_event_file *file) { - if (tracing_alloc_snapshot_instance(file->tr) != 0) - return 0; + int ret = tracing_alloc_snapshot_instance(file->tr); + + if (ret < 0) + return ret; return register_trigger(glob, data, file); }