Skip to content

Commit 410520d

Browse files
committed
Merge tag '9p-for-5.9-rc1' of git://github.com/martinetd/linux
Pull 9p updates from Dominique Martinet: - some code cleanup - a couple of static analysis fixes - setattr: try to pick a fid associated with the file rather than the dentry, which might sometimes matter * tag '9p-for-5.9-rc1' of git://github.com/martinetd/linux: 9p: Remove unneeded cast from memory allocation 9p: remove unused code in 9p net/9p: Fix sparse endian warning in trans_fd.c 9p: Fix memory leak in v9fs_mount 9p: retrieve fid from file when file instance exist.
2 parents f6513bd + 2ed0b75 commit 410520d

File tree

4 files changed

+18
-63
lines changed

4 files changed

+18
-63
lines changed

fs/9p/v9fs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,9 @@ void v9fs_session_close(struct v9fs_session_info *v9ses)
500500
}
501501

502502
#ifdef CONFIG_9P_FSCACHE
503-
if (v9ses->fscache) {
503+
if (v9ses->fscache)
504504
v9fs_cache_session_put_cookie(v9ses);
505-
kfree(v9ses->cachetag);
506-
}
505+
kfree(v9ses->cachetag);
507506
#endif
508507
kfree(v9ses->uname);
509508
kfree(v9ses->aname);

fs/9p/vfs_inode.c

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ v9fs_blank_wstat(struct p9_wstat *wstat)
223223
struct inode *v9fs_alloc_inode(struct super_block *sb)
224224
{
225225
struct v9fs_inode *v9inode;
226-
v9inode = (struct v9fs_inode *)kmem_cache_alloc(v9fs_inode_cache,
227-
GFP_KERNEL);
226+
v9inode = kmem_cache_alloc(v9fs_inode_cache, GFP_KERNEL);
228227
if (!v9inode)
229228
return NULL;
230229
#ifdef CONFIG_9P_FSCACHE
@@ -368,59 +367,6 @@ struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t rdev)
368367
return inode;
369368
}
370369

371-
/*
372-
static struct v9fs_fid*
373-
v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
374-
{
375-
int err;
376-
int nfid;
377-
struct v9fs_fid *ret;
378-
struct v9fs_fcall *fcall;
379-
380-
nfid = v9fs_get_idpool(&v9ses->fidpool);
381-
if (nfid < 0) {
382-
eprintk(KERN_WARNING, "no free fids available\n");
383-
return ERR_PTR(-ENOSPC);
384-
}
385-
386-
err = v9fs_t_walk(v9ses, fid, nfid, (char *) dentry->d_name.name,
387-
&fcall);
388-
389-
if (err < 0) {
390-
if (fcall && fcall->id == RWALK)
391-
goto clunk_fid;
392-
393-
PRINT_FCALL_ERROR("walk error", fcall);
394-
v9fs_put_idpool(nfid, &v9ses->fidpool);
395-
goto error;
396-
}
397-
398-
kfree(fcall);
399-
fcall = NULL;
400-
ret = v9fs_fid_create(v9ses, nfid);
401-
if (!ret) {
402-
err = -ENOMEM;
403-
goto clunk_fid;
404-
}
405-
406-
err = v9fs_fid_insert(ret, dentry);
407-
if (err < 0) {
408-
v9fs_fid_destroy(ret);
409-
goto clunk_fid;
410-
}
411-
412-
return ret;
413-
414-
clunk_fid:
415-
v9fs_t_clunk(v9ses, nfid);
416-
417-
error:
418-
kfree(fcall);
419-
return ERR_PTR(err);
420-
}
421-
*/
422-
423-
424370
/**
425371
* v9fs_clear_inode - release an inode
426372
* @inode: inode to release
@@ -1090,7 +1036,7 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
10901036
{
10911037
int retval;
10921038
struct v9fs_session_info *v9ses;
1093-
struct p9_fid *fid;
1039+
struct p9_fid *fid = NULL;
10941040
struct p9_wstat wstat;
10951041

10961042
p9_debug(P9_DEBUG_VFS, "\n");
@@ -1100,7 +1046,12 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
11001046

11011047
retval = -EPERM;
11021048
v9ses = v9fs_dentry2v9ses(dentry);
1103-
fid = v9fs_fid_lookup(dentry);
1049+
if (iattr->ia_valid & ATTR_FILE) {
1050+
fid = iattr->ia_file->private_data;
1051+
WARN_ON(!fid);
1052+
}
1053+
if (!fid)
1054+
fid = v9fs_fid_lookup(dentry);
11041055
if(IS_ERR(fid))
11051056
return PTR_ERR(fid);
11061057

fs/9p/vfs_inode_dotl.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ static int v9fs_mapped_iattr_valid(int iattr_valid)
540540
int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
541541
{
542542
int retval;
543-
struct p9_fid *fid;
543+
struct p9_fid *fid = NULL;
544544
struct p9_iattr_dotl p9attr;
545545
struct inode *inode = d_inode(dentry);
546546

@@ -560,7 +560,12 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
560560
p9attr.mtime_sec = iattr->ia_mtime.tv_sec;
561561
p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;
562562

563-
fid = v9fs_fid_lookup(dentry);
563+
if (iattr->ia_valid & ATTR_FILE) {
564+
fid = iattr->ia_file->private_data;
565+
WARN_ON(!fid);
566+
}
567+
if (!fid)
568+
fid = v9fs_fid_lookup(dentry);
564569
if (IS_ERR(fid))
565570
return PTR_ERR(fid);
566571

net/9p/trans_fd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ static int p9_bind_privport(struct socket *sock)
950950

951951
memset(&cl, 0, sizeof(cl));
952952
cl.sin_family = AF_INET;
953-
cl.sin_addr.s_addr = INADDR_ANY;
953+
cl.sin_addr.s_addr = htonl(INADDR_ANY);
954954
for (port = p9_ipport_resv_max; port >= p9_ipport_resv_min; port--) {
955955
cl.sin_port = htons((ushort)port);
956956
err = kernel_bind(sock, (struct sockaddr *)&cl, sizeof(cl));

0 commit comments

Comments
 (0)