kthread: Fix return value on kzalloc() failure in kthread_affine_preferred()
PATCH 1/1 kthread: Fix return value on kzalloc() failure in kthread_affine_preferred()
kthread_affine_preferred() incorrectly returns 0 instead of -ENOMEM when kzalloc() fails. Return 'ret' to ensure the correct error code is propagated.
Fixes 4d13f4304fa4 ("kthread: Implement preferred affinity")
Reported-by kernel test robot <[email protected]>
Signed-off-by Yu-Chun Lin <[email protected]>
--- kernel/kthread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/kthread.c +2 -2
@@ -859,7 +859,7 @@ 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; +int ret =0 ;if (!wait_task_inactive (p,TASK_UNINTERRUPTIBLE ) || kthread->started) {WARN_ON (1 );
@@ -892,7 +892,7 @@ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask) out:free_cpumask_var (affinity); -return 0 ; +return ret; }/*
Signature · 1 line
2.43.0
Frederic Weisbecker
AppliedQuoted 8 lines · Yu-Chun Lin
kthread_affine_preferred()incorrectly returns 0 instead of-ENOMEMwhenkzalloc()fails. Return 'ret' to ensure the correct error code is propagated.Fixes 4d13f4304fa4 ("kthread: Implement preferred affinity")Reported-by kernel test robot <[email protected]>Signed-off-by Yu-Chun Lin <[email protected]>
Queued. Thanks!