Skip to content

Commit 156cd28

Browse files
author
Trond Myklebust
committed
NFS: Don't allocate nfs_fattr on the stack in __nfs42_ssc_open()
The preferred behaviour is always to allocate struct nfs_fattr from the slab. Signed-off-by: Trond Myklebust <[email protected]>
1 parent e48c81b commit 156cd28

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
@@ -317,7 +317,7 @@ static int read_name_gen = 1;
317317
static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
318318
struct nfs_fh *src_fh, nfs4_stateid *stateid)
319319
{
320-
struct nfs_fattr fattr;
320+
struct nfs_fattr *fattr = nfs_alloc_fattr();
321321
struct file *filep, *res;
322322
struct nfs_server *server;
323323
struct inode *r_ino = NULL;
@@ -328,9 +328,10 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
328328

329329
server = NFS_SERVER(ss_mnt->mnt_root->d_inode);
330330

331-
nfs_fattr_init(&fattr);
331+
if (!fattr)
332+
return ERR_PTR(-ENOMEM);
332333

333-
status = nfs4_proc_getattr(server, src_fh, &fattr, NULL, NULL);
334+
status = nfs4_proc_getattr(server, src_fh, fattr, NULL, NULL);
334335
if (status < 0) {
335336
res = ERR_PTR(status);
336337
goto out;
@@ -343,7 +344,7 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
343344
goto out;
344345
snprintf(read_name, len, SSC_READ_NAME_BODY, read_name_gen++);
345346

346-
r_ino = nfs_fhget(ss_mnt->mnt_root->d_inode->i_sb, src_fh, &fattr,
347+
r_ino = nfs_fhget(ss_mnt->mnt_root->d_inode->i_sb, src_fh, fattr,
347348
NULL);
348349
if (IS_ERR(r_ino)) {
349350
res = ERR_CAST(r_ino);
@@ -388,6 +389,7 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
388389
out_free_name:
389390
kfree(read_name);
390391
out:
392+
nfs_free_fattr(fattr);
391393
return res;
392394
out_stateowner:
393395
nfs4_put_state_owner(sp);

0 commit comments

Comments
 (0)