[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202502040714.0E55ACBDDB@keescook>
Date: Tue, 4 Feb 2025 07:15:41 -0800
From: Kees Cook <kees@...nel.org>
To: Dhruva Gole <d-gole@...com>
Cc: Frederic Weisbecker <frederic@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Vlastimil Babka <vbabka@...e.cz>, Chen Yu <yu.c.chen@...el.com>,
linux-kernel@...r.kernel.org, Randy Dunlap <rdunlap@...radead.org>
Subject: Re: [PATCH] kthread: Fix build warning variable 'ret' set but not
used
On Tue, Feb 04, 2025 at 02:38:38PM +0530, Dhruva Gole wrote:
> Fix the following build time warning in kthread:
>
> kernel/kthread.c: In function 'kthread_affine_preferred':
> >> kernel/kthread.c:861:13: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
> 861 | int ret;
> | ^~~
>
> Reported-by: kernel test robot <lkp@...el.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202501301528.t0cZVbnq-lkp@intel.com/
> Signed-off-by: Dhruva Gole <d-gole@...com>
> ---
> kernel/kthread.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/kernel/kthread.c b/kernel/kthread.c
> index 4005b13ebd7f..f730b1413d13 100644
> --- a/kernel/kthread.c
> +++ b/kernel/kthread.c
> @@ -859,7 +859,6 @@ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask)
> struct kthread *kthread = to_kthread(p);
> cpumask_var_t affinity;
> unsigned long flags;
> - int ret;
>
> if (!wait_task_inactive(p, TASK_UNINTERRUPTIBLE) || kthread->started) {
> WARN_ON(1);
> @@ -873,7 +872,6 @@ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask)
>
> kthread->preferred_affinity = kzalloc(sizeof(struct cpumask), GFP_KERNEL);
> if (!kthread->preferred_affinity) {
> - ret = -ENOMEM;
> goto out;
> }
This seems wrong? This is an error path, so removing this causes "return
0" to happen. I would take a look at the commit history to figure out
when this mistake was introduced and adjust it correctly. I would have
expected "int ret = 0;", and "return ret;" at "out:" to be the fix.
--
Kees Cook
Powered by blists - more mailing lists