Skip to content

Commit f751c54

Browse files
olgakorn1Trond Myklebust
authored andcommitted
NFSv4.2 fix memory leak in nfs42_ssc_open
Static analysis with Coverity detected a memory leak Reported-by: Colin King <[email protected]> Fixes: ec4b092 ("NFS: inter ssc open") Signed-off-by: Olga Kornievskaia <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 66588ab commit f751c54

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/nfs/nfs4file.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh,
318318
struct inode *r_ino = NULL;
319319
struct nfs_open_context *ctx;
320320
struct nfs4_state_owner *sp;
321-
char *read_name;
321+
char *read_name = NULL;
322322
int len, status = 0;
323323

324324
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,
342342
NULL);
343343
if (IS_ERR(r_ino)) {
344344
res = ERR_CAST(r_ino);
345-
goto out;
345+
goto out_free_name;
346346
}
347347

348348
filep = alloc_file_pseudo(r_ino, ss_mnt, read_name, FMODE_READ,
349349
r_ino->i_fop);
350350
if (IS_ERR(filep)) {
351351
res = ERR_CAST(filep);
352-
goto out;
352+
goto out_free_name;
353353
}
354354
filep->f_mode |= FMODE_READ;
355355

@@ -380,6 +380,8 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh,
380380

381381
file_ra_state_init(&filep->f_ra, filep->f_mapping->host->i_mapping);
382382
res = filep;
383+
out_free_name:
384+
kfree(read_name);
383385
out:
384386
return res;
385387
out_stateowner:
@@ -388,7 +390,7 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh,
388390
put_nfs_open_context(ctx);
389391
out_filep:
390392
fput(filep);
391-
goto out;
393+
goto out_free_name;
392394
}
393395
EXPORT_SYMBOL_GPL(nfs42_ssc_open);
394396
void nfs42_ssc_close(struct file *filep)

0 commit comments

Comments
 (0)