NFSv4: Fixup smatch warning for ambiguous return
Dan Carpenter reports smatch warning for nfs4_try_migration() when a memory
allocation failure results in a zero return value. In this case, a
transient allocation failure error will likely be retried the next time the
server responds with NFS4ERR_MOVED.
We can fixup the smatch warning with a small refactor: attempt all three
allocations before testing and returning on a failure.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: c3ed222745
("NFSv4: Fix free of uninitialized nfs4_label on referral lookup.")
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
parent
bf95f82e6a
commit
37ffe06537
@ -2116,6 +2116,7 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred
|
|||||||
{
|
{
|
||||||
struct nfs_client *clp = server->nfs_client;
|
struct nfs_client *clp = server->nfs_client;
|
||||||
struct nfs4_fs_locations *locations = NULL;
|
struct nfs4_fs_locations *locations = NULL;
|
||||||
|
struct nfs_fattr *fattr;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
int status, result;
|
int status, result;
|
||||||
@ -2125,19 +2126,16 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred
|
|||||||
(unsigned long long)server->fsid.minor,
|
(unsigned long long)server->fsid.minor,
|
||||||
clp->cl_hostname);
|
clp->cl_hostname);
|
||||||
|
|
||||||
result = 0;
|
|
||||||
page = alloc_page(GFP_KERNEL);
|
page = alloc_page(GFP_KERNEL);
|
||||||
locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL);
|
locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL);
|
||||||
if (page == NULL || locations == NULL) {
|
fattr = nfs_alloc_fattr();
|
||||||
dprintk("<-- %s: no memory\n", __func__);
|
if (page == NULL || locations == NULL || fattr == NULL) {
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
locations->fattr = nfs_alloc_fattr();
|
|
||||||
if (locations->fattr == NULL) {
|
|
||||||
dprintk("<-- %s: no memory\n", __func__);
|
dprintk("<-- %s: no memory\n", __func__);
|
||||||
|
result = 0;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
locations->fattr = fattr;
|
||||||
inode = d_inode(server->super->s_root);
|
inode = d_inode(server->super->s_root);
|
||||||
result = nfs4_proc_get_locations(server, NFS_FH(inode), locations,
|
result = nfs4_proc_get_locations(server, NFS_FH(inode), locations,
|
||||||
page, cred);
|
page, cred);
|
||||||
|
Loading…
Reference in New Issue
Block a user