All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: fix potential memory leak in mount option parsing
@ 2018-02-24 10:33 Chengguang Xu
  2018-02-24 17:58 ` Eric Sandeen
  2018-02-26  2:47 ` Eric Sandeen
  0 siblings, 2 replies; 9+ messages in thread
From: Chengguang Xu @ 2018-02-24 10:33 UTC (permalink / raw)
  To: darrick.wong; +Cc: linux-xfs, Chengguang Xu

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>
---
 fs/xfs/xfs_super.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 7aba628..93588ea 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -250,6 +250,7 @@ enum {
 				return -EINVAL;
 			break;
 		case Opt_logdev:
+			kfree(mp->m_logname);
 			mp->m_logname = match_strdup(args);
 			if (!mp->m_logname)
 				return -ENOMEM;
@@ -258,6 +259,7 @@ enum {
 			xfs_warn(mp, "%s option not allowed on this system", p);
 			return -EINVAL;
 		case Opt_rtdev:
+			kfree(mp->m_rtname);
 			mp->m_rtname = match_strdup(args);
 			if (!mp->m_rtname)
 				return -ENOMEM;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-02-26  2:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-24 10:33 [PATCH] xfs: fix potential memory leak in mount option parsing Chengguang Xu
2018-02-24 17:58 ` Eric Sandeen
2018-02-25  4:11   ` Chengguang Xu
2018-02-25 18:09     ` Darrick J. Wong
2018-02-25 18:11       ` Eric Sandeen
2018-02-25 21:05         ` Dave Chinner
2018-02-25 21:15           ` Eric Sandeen
2018-02-26  1:49         ` Chengguang Xu
2018-02-26  2:47 ` Eric Sandeen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.