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>
+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)
STATIC void
xfs_fs_put_super(
struct super_block *sb)
xfs_close_devices(mp);
xfs_qmops_put(mp);
xfs_dmops_put(mp);
xfs_close_devices(mp);
xfs_qmops_put(mp);
xfs_dmops_put(mp);
struct xfs_mount_args *ap,
struct xfs_mount *mp)
{
struct xfs_mount_args *ap,
struct xfs_mount *mp)
{
/* Values are in BBs */
if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
/*
/* Values are in BBs */
if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
/*
ap->logbufsize);
return XFS_ERROR(EINVAL);
}
ap->logbufsize);
return XFS_ERROR(EINVAL);
}
mp->m_logbsize = ap->logbufsize;
mp->m_fsname_len = strlen(ap->fsname) + 1;
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;
+
- 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;
+
- 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)
}
if (ap->flags & XFSMNT_WSYNC)
if (ap->flags & XFSMNT_DMAPI)
mp->m_flags |= XFS_MOUNT_DMAPI;
return 0;
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;
*/
error = xfs_start_flags(args, mp);
if (error)
*/
error = xfs_start_flags(args, mp);
if (error)
- goto out_destroy_counters;
error = xfs_readsb(mp, flags);
if (error)
error = xfs_readsb(mp, flags);
if (error)
- goto out_destroy_counters;
error = xfs_finish_flags(args, mp);
if (error)
goto out_free_sb;
error = xfs_finish_flags(args, mp);
if (error)
goto out_free_sb;
xfs_filestream_unmount(mp);
out_free_sb:
xfs_freesb(mp);
xfs_filestream_unmount(mp);
out_free_sb:
xfs_freesb(mp);
+ out_free_fsname:
+ xfs_free_fsname(mp);
xfs_icsb_destroy_counters(mp);
xfs_close_devices(mp);
out_put_qmops:
xfs_icsb_destroy_counters(mp);
xfs_close_devices(mp);
out_put_qmops:
IRELE(mp->m_rootip);
xfs_unmountfs(mp);
IRELE(mp->m_rootip);
xfs_unmountfs(mp);
- goto out_destroy_counters;
mutex_destroy(&mp->m_growlock);
if (mp->m_quotainfo)
XFS_QM_DONE(mp);
mutex_destroy(&mp->m_growlock);
if (mp->m_quotainfo)
XFS_QM_DONE(mp);
-
- if (mp->m_fsname != NULL)
- kmem_free(mp->m_fsname);
- if (mp->m_rtname != NULL)
- kmem_free(mp->m_rtname);
- if (mp->m_logname != NULL)
- kmem_free(mp->m_logname);