2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-21 11:44:01 +08:00

NFSv4.2 fix memory leak in nfs42_ssc_open

Static analysis with Coverity detected a memory leak

Reported-by: Colin King <colin.king@canonical.com>
Fixes: ec4b092508 ("NFS: inter ssc open")
Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
Olga Kornievskaia 2019-11-15 15:13:19 -05:00 committed by Trond Myklebust
parent 66588abe2d
commit f751c54525

View File

@ -318,7 +318,7 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh,
struct inode *r_ino = NULL; struct inode *r_ino = NULL;
struct nfs_open_context *ctx; struct nfs_open_context *ctx;
struct nfs4_state_owner *sp; struct nfs4_state_owner *sp;
char *read_name; char *read_name = NULL;
int len, status = 0; int len, status = 0;
server = NFS_SERVER(ss_mnt->mnt_root->d_inode); server = NFS_SERVER(ss_mnt->mnt_root->d_inode);
@ -342,14 +342,14 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh,
NULL); NULL);
if (IS_ERR(r_ino)) { if (IS_ERR(r_ino)) {
res = ERR_CAST(r_ino); res = ERR_CAST(r_ino);
goto out; goto out_free_name;
} }
filep = alloc_file_pseudo(r_ino, ss_mnt, read_name, FMODE_READ, filep = alloc_file_pseudo(r_ino, ss_mnt, read_name, FMODE_READ,
r_ino->i_fop); r_ino->i_fop);
if (IS_ERR(filep)) { if (IS_ERR(filep)) {
res = ERR_CAST(filep); res = ERR_CAST(filep);
goto out; goto out_free_name;
} }
filep->f_mode |= FMODE_READ; filep->f_mode |= FMODE_READ;
@ -380,6 +380,8 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh,
file_ra_state_init(&filep->f_ra, filep->f_mapping->host->i_mapping); file_ra_state_init(&filep->f_ra, filep->f_mapping->host->i_mapping);
res = filep; res = filep;
out_free_name:
kfree(read_name);
out: out:
return res; return res;
out_stateowner: out_stateowner:
@ -388,7 +390,7 @@ out_ctx:
put_nfs_open_context(ctx); put_nfs_open_context(ctx);
out_filep: out_filep:
fput(filep); fput(filep);
goto out; goto out_free_name;
} }
EXPORT_SYMBOL_GPL(nfs42_ssc_open); EXPORT_SYMBOL_GPL(nfs42_ssc_open);
void nfs42_ssc_close(struct file *filep) void nfs42_ssc_close(struct file *filep)