Currently, we do not check the return value of client = rpc_clone_client(), nor do we shut down the resulting cloned rpc_clnt in the case where a NFS4ERR_WRONGSEC has caused nfs4_proc_lookup_common() to replace the original value of 'client' (causing a memory leak). Fix both issues and simplify the code by moving the call to rpc_clone_client() until after nfs4_proc_lookup_common() has done its business.
Unified · Split
| @@ -3071,15 +3071,13 @@ struct rpc_clnt * · 3070 unmodified lines | |||
| 3071 | nfs4_proc_lookup_mountpoint(struct inode *dir, struct qstr *name, | 3071 | nfs4_proc_lookup_mountpoint(struct inode *dir, struct qstr *name, |
| 3072 | struct nfs_fh *fhandle, struct nfs_fattr *fattr) | 3072 | struct nfs_fh *fhandle, struct nfs_fattr *fattr) |
| 3073 | { | 3073 | { |
| 3074 | struct rpc_clnt *client = NFS_CLIENT(dir); | ||
| 3074 | int status; | 3075 | int status; |
| 3075 | struct rpc_clnt *client = rpc_clone_client(NFS_CLIENT(dir)); | ||
| 3076 | 3076 | ||
| 3077 | status = nfs4_proc_lookup_common(&client, dir, name, fhandle, fattr, NULL); | 3077 | status = nfs4_proc_lookup_common(&client, dir, name, fhandle, fattr, NULL); |
| 3078 | if (status < 0) { | 3078 | if (status < 0) |
| 3079 | rpc_shutdown_client(client); | ||
| 3080 | return ERR_PTR(status); | 3079 | return ERR_PTR(status); |
| 3081 | } | 3080 | return (client == NFS_CLIENT(dir)) ? rpc_clone_client(client) : client; |
| 3082 | return client; | ||
| 3083 | } | 3081 | } |
| 3084 | 3082 | ||
| 3085 | static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) | 3083 | static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) |