mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
mm/shrinker: fix name consistency issue in shrinker_debugfs_rename()
After calling debugfs_change_name function, the return value should be checked and the old name restored. If debugfs_change_name fails, the new name memory should be freed. The effect is that the shrinker->name is not consistent with the name displayed in debugfs. Link: https://lkml.kernel.org/r/20250305071759.661055-1-liuye@kylinos.cn Signed-off-by: Liu Ye <liuye@kylinos.cn> Reviewed-by: Muchun Song <muchun.song@linux.dev> Reviewed-by:Qi Zheng <zhengqi.arch@bytedance.co Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev> Cc: Dave Chinner <david@fromorbit.com> Cc: Muchun Song <muchun.song@linux.dev> Cc: Qi Zheng <zhengqi.arch@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
9ea705a54b
commit
ac55b38fe2
@ -214,9 +214,13 @@ int shrinker_debugfs_rename(struct shrinker *shrinker, const char *fmt, ...)
|
|||||||
ret = debugfs_change_name(shrinker->debugfs_entry, "%s-%d",
|
ret = debugfs_change_name(shrinker->debugfs_entry, "%s-%d",
|
||||||
shrinker->name, shrinker->debugfs_id);
|
shrinker->name, shrinker->debugfs_id);
|
||||||
|
|
||||||
mutex_unlock(&shrinker_mutex);
|
if (ret) {
|
||||||
|
shrinker->name = old;
|
||||||
|
kfree_const(new);
|
||||||
|
} else {
|
||||||
kfree_const(old);
|
kfree_const(old);
|
||||||
|
}
|
||||||
|
mutex_unlock(&shrinker_mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user