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 D1B3A186E54 for ; Wed, 8 Jan 2025 03:35:33 +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=1736307333; cv=none; b=ZpRBHdxuLhFW/+iF1QpS2lEKCySQuXt5NDkaC2QShR0790e7BwchCj6BpP2sTjWqq8pL537R5iAaSMuXafKaWeUIaG5EjuMDg+z8dnUccPSFAaEfV/vxoqDl4oFFS+/suthJR5+hrW4IaLtdu0yR/HcBXihlmtK0derccDAg1+8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736307333; c=relaxed/simple; bh=clkgdICUjAcE4+loZX1YnYJB2wUdRXSbI7IoTOTpaOo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=K5GPgjfiwwcW1oH/57WbMo7O/44vd9QxFwo3fbC9j/Gl5sQnx8f39GAXJRzBxqQW8Hg44t4Mv8vYGM5H9CEecS3/kkN2CQLi4zFXYo5TJ9DgMmG+Qb5UGBpmEiDwguFypdw0UtPwD0QsapLW0ht4ocOUGLDvxEuvmbd8gWDmawM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BCE2C4CEE1; Wed, 8 Jan 2025 03:35:33 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tVMsR-0000000ApAc-2o8H; Tue, 07 Jan 2025 22:37:03 -0500 Message-ID: <20250108033703.517765134@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 07 Jan 2025 22:36:48 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , kernel test robot , Dan Carpenter Subject: [for-next][PATCH 1/4] tracing: Fix using ret variable in tracing_set_tracer() References: <20250108033647.656576164@goodmis.org> 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 From: Steven Rostedt When the function tracing_set_tracer() switched over to using the guard() infrastructure, it did not need to save the 'ret' variable and would just return the value when an error arised, instead of setting ret and jumping to an out label. When CONFIG_TRACER_SNAPSHOT is enabled, it had code that expected the "ret" variable to be initialized to zero and had set 'ret' while holding an arch_spin_lock() (not used by guard), and then upon releasing the lock it would check 'ret' and exit if set. But because ret was only set when an error occurred while holding the locks, 'ret' would be used uninitialized if there was no error. The code in the CONFIG_TRACER_SNAPSHOT block should be self contain. Make sure 'ret' is also set when no error occurred. Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20250106111143.2f90ff65@gandalf.local.home Reported-by: kernel test robot Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202412271654.nJVBuwmF-lkp@intel.com/ Fixes: d33b10c0c73ad ("tracing: Switch trace.c code over to use guard()") Signed-off-by: Steven Rostedt (Google) Acked-by: Masami Hiramatsu (Google) --- kernel/trace/trace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 0aaf442271e9..5aeb898054e7 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -6104,8 +6104,7 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf) if (t->use_max_tr) { local_irq_disable(); arch_spin_lock(&tr->max_lock); - if (tr->cond_snapshot) - ret = -EBUSY; + ret = tr->cond_snapshot ? -EBUSY : 0; arch_spin_unlock(&tr->max_lock); local_irq_enable(); if (ret) -- 2.45.2