Skip to content

Commit 5b4c845

Browse files
Chengguang Xudjwong
authored andcommitted
xfs: fix potential memory leak in mount option parsing
When specifying string type mount option (e.g., logdev) several times in a mount, current option parsing may cause memory leak. Hence, call kfree for previous one in this case. Signed-off-by: Chengguang Xu <cgxu519@icloud.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
1 parent b31c2bd commit 5b4c845

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/xfs/xfs_super.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ xfs_parseargs(
250250
return -EINVAL;
251251
break;
252252
case Opt_logdev:
253+
kfree(mp->m_logname);
253254
mp->m_logname = match_strdup(args);
254255
if (!mp->m_logname)
255256
return -ENOMEM;
@@ -258,6 +259,7 @@ xfs_parseargs(
258259
xfs_warn(mp, "%s option not allowed on this system", p);
259260
return -EINVAL;
260261
case Opt_rtdev:
262+
kfree(mp->m_rtname);
261263
mp->m_rtname = match_strdup(args);
262264
if (!mp->m_rtname)
263265
return -ENOMEM;

0 commit comments

Comments
 (0)