Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp309165rdb; Thu, 25 Jan 2024 16:43:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqoH7OYCxnoTcCR7dLYesSlcjmxcJOgv5x6X/6iRV+QlDYvv3xGbcQBMbH32FJfpAuiEYf X-Received: by 2002:a05:6808:2194:b0:3bd:c174:b240 with SMTP id be20-20020a056808219400b003bdc174b240mr619077oib.94.1706229789360; Thu, 25 Jan 2024 16:43:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706229789; cv=pass; d=google.com; s=arc-20160816; b=sK3JuwNg0YfN9caFLNPOIcyyvx1CaKGsHBtw+x18EeHgb2GZld7inXklD6ldRjee6k jY4JxJGTo/75+X853Y9tIhWDm1eU/56UMBGXXfzs/l2CG99SOOLGGCBcD9PZCmS2OBMn vz6GJOrzJDvoeBgyAKLm4y5BB52bu45Z/wkUUh1N3GBFBEpiLTB0sk96XiBnX4Uq5h+U My7bLmu+1eNh+e7GawaHuDP3HfGxTaJYDb3XoKfvxyb/O36H4X8T8s4uHee77Q6tepml it5IhI/IWsw1KJXJfqZo7JrBz8+2m6jR9SzKjq4ifkrdE5FLrjInTJqjIel0k3ygG2jF bohw== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39465-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j2-20020a37c242000000b00783b6ef2b2fsi146019qkm.722.2024.01.25.16.43.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 16:43:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39465-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39465-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1E0DA1C23388 for ; Fri, 26 Jan 2024 00:43:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 508A4EBE; Fri, 26 Jan 2024 00:43:03 +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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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); }