Commit bdd907ba authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Niv Sardi

[XFS] allow xfs_args_allocate to fail

Switch xfs_args_allocate to kzalloc and handle failures.

SGI-PV: 981951
SGI-Modid: xfs-linux-melb:xfs-kern:31195a
Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarDavid Chinner <dgc@sgi.com>
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
parent e34b562c
...@@ -75,7 +75,10 @@ xfs_args_allocate( ...@@ -75,7 +75,10 @@ xfs_args_allocate(
{ {
struct xfs_mount_args *args; struct xfs_mount_args *args;
args = kmem_zalloc(sizeof(struct xfs_mount_args), KM_SLEEP); args = kzalloc(sizeof(struct xfs_mount_args), GFP_KERNEL);
if (!args)
return NULL;
args->logbufs = args->logbufsize = -1; args->logbufs = args->logbufsize = -1;
strncpy(args->fsname, sb->s_id, MAXNAMELEN); strncpy(args->fsname, sb->s_id, MAXNAMELEN);
...@@ -1396,9 +1399,13 @@ xfs_fs_remount( ...@@ -1396,9 +1399,13 @@ xfs_fs_remount(
char *options) char *options)
{ {
struct xfs_mount *mp = XFS_M(sb); struct xfs_mount *mp = XFS_M(sb);
struct xfs_mount_args *args = xfs_args_allocate(sb, 0); struct xfs_mount_args *args;
int error; int error;
args = xfs_args_allocate(sb, 0);
if (!args)
return -ENOMEM;
error = xfs_parseargs(mp, options, args, 1); error = xfs_parseargs(mp, options, args, 1);
if (error) if (error)
goto out_free_args; goto out_free_args;
...@@ -1420,7 +1427,7 @@ xfs_fs_remount( ...@@ -1420,7 +1427,7 @@ xfs_fs_remount(
} }
out_free_args: out_free_args:
kmem_free(args); kfree(args);
return -error; return -error;
} }
...@@ -1725,9 +1732,13 @@ xfs_fs_fill_super( ...@@ -1725,9 +1732,13 @@ xfs_fs_fill_super(
{ {
struct inode *root; struct inode *root;
struct xfs_mount *mp = NULL; struct xfs_mount *mp = NULL;
struct xfs_mount_args *args = xfs_args_allocate(sb, silent); struct xfs_mount_args *args;
int flags = 0, error; int flags = 0, error;
args = xfs_args_allocate(sb, silent);
if (!args)
return -ENOMEM;
mp = xfs_mount_init(); mp = xfs_mount_init();
INIT_LIST_HEAD(&mp->m_sync_list); INIT_LIST_HEAD(&mp->m_sync_list);
...@@ -1826,7 +1837,7 @@ xfs_fs_fill_super( ...@@ -1826,7 +1837,7 @@ xfs_fs_fill_super(
xfs_itrace_exit(XFS_I(sb->s_root->d_inode)); xfs_itrace_exit(XFS_I(sb->s_root->d_inode));
kmem_free(args); kfree(args);
return 0; return 0;
error2: error2:
...@@ -1874,7 +1885,7 @@ xfs_fs_fill_super( ...@@ -1874,7 +1885,7 @@ xfs_fs_fill_super(
kmem_free(mp); kmem_free(mp);
fail_vfsop: fail_vfsop:
kmem_free(args); kfree(args);
return -error; return -error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment