Commit 083fd8b2 authored by David Howells's avatar David Howells Committed by Linus Torvalds

AFS: Don't pass error value to page_cache_release() in error handling

In the error handling in afs_mntpt_do_automount(), we pass an error
pointer to page_cache_release() if read_mapping_page() failed.  Instead,
we should extend the gotos around the error handling we don't need.
Reported-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 05ce7bfe
...@@ -138,9 +138,9 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) ...@@ -138,9 +138,9 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
{ {
struct afs_super_info *super; struct afs_super_info *super;
struct vfsmount *mnt; struct vfsmount *mnt;
struct page *page = NULL; struct page *page;
size_t size; size_t size;
char *buf, *devname = NULL, *options = NULL; char *buf, *devname, *options;
int ret; int ret;
_enter("{%s}", mntpt->d_name.name); _enter("{%s}", mntpt->d_name.name);
...@@ -150,22 +150,22 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) ...@@ -150,22 +150,22 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
ret = -EINVAL; ret = -EINVAL;
size = mntpt->d_inode->i_size; size = mntpt->d_inode->i_size;
if (size > PAGE_SIZE - 1) if (size > PAGE_SIZE - 1)
goto error; goto error_no_devname;
ret = -ENOMEM; ret = -ENOMEM;
devname = (char *) get_zeroed_page(GFP_KERNEL); devname = (char *) get_zeroed_page(GFP_KERNEL);
if (!devname) if (!devname)
goto error; goto error_no_devname;
options = (char *) get_zeroed_page(GFP_KERNEL); options = (char *) get_zeroed_page(GFP_KERNEL);
if (!options) if (!options)
goto error; goto error_no_options;
/* read the contents of the AFS special symlink */ /* read the contents of the AFS special symlink */
page = read_mapping_page(mntpt->d_inode->i_mapping, 0, NULL); page = read_mapping_page(mntpt->d_inode->i_mapping, 0, NULL);
if (IS_ERR(page)) { if (IS_ERR(page)) {
ret = PTR_ERR(page); ret = PTR_ERR(page);
goto error; goto error_no_page;
} }
ret = -EIO; ret = -EIO;
...@@ -196,12 +196,12 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) ...@@ -196,12 +196,12 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
return mnt; return mnt;
error: error:
if (page)
page_cache_release(page); page_cache_release(page);
if (devname) error_no_page:
free_page((unsigned long) devname);
if (options)
free_page((unsigned long) options); free_page((unsigned long) options);
error_no_options:
free_page((unsigned long) devname);
error_no_devname:
_leave(" = %d", ret); _leave(" = %d", ret);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
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