Commit 41ffaa0e authored by Joshua Hahn's avatar Joshua Hahn Committed by Andrew Morton
Browse files

mm/mempolicy: fix incorrect freeing of wi_kobj

We should not free wi_group->wi_kobj here.  In the error path of
add_weighted_interleave_group() where this snippet is called from,
kobj_{del, put} is immediately called right after this section.  Thus, it
is not only unnecessary but also incorrect to free it here.

Link: https://lkml.kernel.org/r/20250602162345.2595696-1-joshua.hahnjy@gmail.com


Fixes: e341f9c3 ("mm/mempolicy: Weighted Interleave Auto-tuning")
Signed-off-by: default avatarJoshua Hahn <joshua.hahnjy@gmail.com>
Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202506011545.Fduxqxqj-lkp@intel.com/


Cc: Alistair Popple <apopple@nvidia.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Mathew Brost <matthew.brost@intel.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 044d2aee
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -3708,15 +3708,13 @@ static void wi_state_free(void)
			lockdep_is_held(&wi_state_lock));
	if (!old_wi_state) {
		mutex_unlock(&wi_state_lock);
		goto out;
		return;
	}

	rcu_assign_pointer(wi_state, NULL);
	mutex_unlock(&wi_state_lock);
	synchronize_rcu();
	kfree(old_wi_state);
out:
	kfree(&wi_group->wi_kobj);
}

static struct kobj_attribute wi_auto_attr =