diff mbox series

[v2,1/1] mkfs: Fix memory leak

Message ID 20220524220509.967287-2-preichl@redhat.com (mailing list archive)
State Accepted
Headers show
Series mkfs: Fix memory leark | expand

Commit Message

Pavel Reichl May 24, 2022, 10:05 p.m. UTC
'value' is allocated by strdup() in getstr(). It
needs to be freed as we do not keep any permanent
reference to it.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
 mkfs/xfs_mkfs.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Chaitanya Kulkarni May 25, 2022, 7:24 a.m. UTC | #1
On 5/24/22 15:05, Pavel Reichl wrote:
> 'value' is allocated by strdup() in getstr(). It
> needs to be freed as we do not keep any permanent
> reference to it.
> 
> Signed-off-by: Pavel Reichl <preichl@redhat.com>
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> ---

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
diff mbox series

Patch

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 01d2e8ca..a37d6848 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1714,6 +1714,7 @@  naming_opts_parser(
 		} else {
 			cli->sb_feat.dir_version = getnum(value, opts, subopt);
 		}
+		free((char *)value);
 		break;
 	case N_FTYPE:
 		cli->sb_feat.dirftype = getnum(value, opts, subopt);