Skip to content

Commit fc0d192

Browse files
dmantipovcmaiolino
authored andcommitted
xfs: scrub: use kstrdup_const() for metapath scan setups
Except 'xchk_setup_metapath_rtginode()' case, 'path' argument of 'xchk_setup_metapath_scan()' is a compile-time constant. So it may be reasonable to use 'kstrdup_const()' / 'kree_const()' to manage 'path' field of 'struct xchk_metapath' in attempt to reuse .rodata instance rather than making a copy. Compile tested only. Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 6ef2175 commit fc0d192

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

fs/xfs/scrub/metapath.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ xchk_metapath_cleanup(
7979

8080
if (mpath->dp_ilock_flags)
8181
xfs_iunlock(mpath->dp, mpath->dp_ilock_flags);
82-
kfree(mpath->path);
82+
kfree_const(mpath->path);
8383
}
8484

8585
/* Set up a metadir path scan. @path must be dynamically allocated. */
@@ -98,13 +98,13 @@ xchk_setup_metapath_scan(
9898

9999
error = xchk_install_live_inode(sc, ip);
100100
if (error) {
101-
kfree(path);
101+
kfree_const(path);
102102
return error;
103103
}
104104

105105
mpath = kzalloc(sizeof(struct xchk_metapath), XCHK_GFP_FLAGS);
106106
if (!mpath) {
107-
kfree(path);
107+
kfree_const(path);
108108
return -ENOMEM;
109109
}
110110

@@ -132,7 +132,7 @@ xchk_setup_metapath_rtdir(
132132
return -ENOENT;
133133

134134
return xchk_setup_metapath_scan(sc, sc->mp->m_metadirip,
135-
kasprintf(GFP_KERNEL, "rtgroups"), sc->mp->m_rtdirip);
135+
kstrdup_const("rtgroups", GFP_KERNEL), sc->mp->m_rtdirip);
136136
}
137137

138138
/* Scan a rtgroup inode under the /rtgroups directory. */
@@ -179,7 +179,7 @@ xchk_setup_metapath_quotadir(
179179
return -ENOENT;
180180

181181
return xchk_setup_metapath_scan(sc, sc->mp->m_metadirip,
182-
kstrdup("quota", GFP_KERNEL), qi->qi_dirip);
182+
kstrdup_const("quota", GFP_KERNEL), qi->qi_dirip);
183183
}
184184

185185
/* Scan a quota inode under the /quota directory. */
@@ -212,7 +212,7 @@ xchk_setup_metapath_dqinode(
212212
return -ENOENT;
213213

214214
return xchk_setup_metapath_scan(sc, qi->qi_dirip,
215-
kstrdup(xfs_dqinode_path(type), GFP_KERNEL), ip);
215+
kstrdup_const(xfs_dqinode_path(type), GFP_KERNEL), ip);
216216
}
217217
#else
218218
# define xchk_setup_metapath_quotadir(...) (-ENOENT)

0 commit comments

Comments
 (0)