aboutsummaryrefslogtreecommitdiff
path: root/fs/xfs/linux-2.6/xfs_super.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-08-13 16:04:05 +1000
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-08-13 16:04:05 +1000
commita738159df2b97398f960978272944cbdd8f726ef (patch)
tree20959d5f1d941dd7c755bf9bc8141f20f97249dd /fs/xfs/linux-2.6/xfs_super.c
parent5e9da7b7a1edfc75a839b0269935393fa347f38b (diff)
[XFS] don't leak m_fsname/m_rtname/m_logname
Add a helper to free the m_fsname/m_rtname/m_logname allocations and use it properly for all mount failure cases. Also switch the allocations for these to kstrdup while we're at it. SGI-PV: 981498 SGI-Modid: xfs-linux-melb:xfs-kern:31728a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Niv Sardi <xaiki@sgi.com> Signed-off-by: David Chinner <david@fromorbit.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_super.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index c9ec44a02e2..27758409fc8 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1201,6 +1201,15 @@ xfssyncd(
}
STATIC void
+xfs_free_fsname(
+ struct xfs_mount *mp)
+{
+ kfree(mp->m_fsname);
+ kfree(mp->m_rtname);
+ kfree(mp->m_logname);
+}
+
+STATIC void
xfs_fs_put_super(
struct super_block *sb)
{
@@ -1261,6 +1270,7 @@ xfs_fs_put_super(
xfs_close_devices(mp);
xfs_qmops_put(mp);
xfs_dmops_put(mp);
+ xfs_free_fsname(mp);
kfree(mp);
}
@@ -1517,6 +1527,8 @@ xfs_start_flags(
struct xfs_mount_args *ap,
struct xfs_mount *mp)
{
+ int error;
+
/* Values are in BBs */
if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
/*
@@ -1549,17 +1561,27 @@ xfs_start_flags(
ap->logbufsize);
return XFS_ERROR(EINVAL);
}
+
+ error = ENOMEM;
+
mp->m_logbsize = ap->logbufsize;
mp->m_fsname_len = strlen(ap->fsname) + 1;
- mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP);
- strcpy(mp->m_fsname, ap->fsname);
+
+ mp->m_fsname = kstrdup(ap->fsname, GFP_KERNEL);
+ if (!mp->m_fsname)
+ goto out;
+
if (ap->rtname[0]) {
- mp->m_rtname = kmem_alloc(strlen(ap->rtname) + 1, KM_SLEEP);
- strcpy(mp->m_rtname, ap->rtname);
+ mp->m_rtname = kstrdup(ap->rtname, GFP_KERNEL);
+ if (!mp->m_rtname)
+ goto out_free_fsname;
+
}
+
if (ap->logname[0]) {
- mp->m_logname = kmem_alloc(strlen(ap->logname) + 1, KM_SLEEP);
- strcpy(mp->m_logname, ap->logname);
+ mp->m_logname = kstrdup(ap->logname, GFP_KERNEL);
+ if (!mp->m_logname)
+ goto out_free_rtname;
}
if (ap->flags & XFSMNT_WSYNC)
@@ -1632,6 +1654,14 @@ xfs_start_flags(
if (ap->flags & XFSMNT_DMAPI)
mp->m_flags |= XFS_MOUNT_DMAPI;
return 0;
+
+
+ out_free_rtname:
+ kfree(mp->m_rtname);
+ out_free_fsname:
+ kfree(mp->m_fsname);
+ out:
+ return error;
}
/*
@@ -1792,10 +1822,10 @@ xfs_fs_fill_super(
*/
error = xfs_start_flags(args, mp);
if (error)
- goto out_destroy_counters;
+ goto out_free_fsname;
error = xfs_readsb(mp, flags);
if (error)
- goto out_destroy_counters;
+ goto out_free_fsname;
error = xfs_finish_flags(args, mp);
if (error)
goto out_free_sb;
@@ -1857,7 +1887,8 @@ xfs_fs_fill_super(
xfs_filestream_unmount(mp);
out_free_sb:
xfs_freesb(mp);
- out_destroy_counters:
+ out_free_fsname:
+ xfs_free_fsname(mp);
xfs_icsb_destroy_counters(mp);
xfs_close_devices(mp);
out_put_qmops:
@@ -1893,7 +1924,7 @@ xfs_fs_fill_super(
IRELE(mp->m_rootip);
xfs_unmountfs(mp);
- goto out_destroy_counters;
+ goto out_free_fsname;
}
STATIC int