int status;
 
        atomic_inc(&data->count);
+       /*
+        * If rpc_run_task() ends up calling ->rpc_release(), we
+        * want to ensure that it takes the 'error' code path.
+        */
+       data->rpc_status = -ENOMEM;
        task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_confirm_ops, data);
-       if (IS_ERR(task)) {
-               nfs4_opendata_free(data);
+       if (IS_ERR(task))
                return PTR_ERR(task);
-       }
        status = nfs4_wait_for_completion_rpc_task(task);
        if (status != 0) {
                data->cancelled = 1;
        int status;
 
        atomic_inc(&data->count);
+       /*
+        * If rpc_run_task() ends up calling ->rpc_release(), we
+        * want to ensure that it takes the 'error' code path.
+        */
+       data->rpc_status = -ENOMEM;
        task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_ops, data);
-       if (IS_ERR(task)) {
-               nfs4_opendata_free(data);
+       if (IS_ERR(task))
                return PTR_ERR(task);
-       }
        status = nfs4_wait_for_completion_rpc_task(task);
        if (status != 0) {
                data->cancelled = 1;
        data->rpc_status = 0;
 
        task = rpc_run_task(NFS_CLIENT(inode), RPC_TASK_ASYNC, &nfs4_delegreturn_ops, data);
-       if (IS_ERR(task)) {
-               nfs4_delegreturn_release(data);
+       if (IS_ERR(task))
                return PTR_ERR(task);
-       }
        status = nfs4_wait_for_completion_rpc_task(task);
        if (status == 0) {
                status = data->rpc_status;
                struct nfs_seqid *seqid)
 {
        struct nfs4_unlockdata *data;
-       struct rpc_task *task;
 
        data = nfs4_alloc_unlockdata(fl, ctx, lsp, seqid);
        if (data == NULL) {
 
        /* Unlock _before_ we do the RPC call */
        do_vfs_lock(fl->fl_file, fl);
-       task = rpc_run_task(NFS_CLIENT(lsp->ls_state->inode), RPC_TASK_ASYNC, &nfs4_locku_ops, data);
-       if (IS_ERR(task))
-               nfs4_locku_release_calldata(data);
-       return task;
+       return rpc_run_task(NFS_CLIENT(lsp->ls_state->inode), RPC_TASK_ASYNC, &nfs4_locku_ops, data);
 }
 
 static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request)
                data->arg.reclaim = 1;
        task = rpc_run_task(NFS_CLIENT(state->inode), RPC_TASK_ASYNC,
                        &nfs4_lock_ops, data);
-       if (IS_ERR(task)) {
-               nfs4_lock_release(data);
+       if (IS_ERR(task))
                return PTR_ERR(task);
-       }
        ret = nfs4_wait_for_completion_rpc_task(task);
        if (ret == 0) {
                ret = data->rpc_status;
 
        int             status;
 
        /* If this client is slain all further I/O fails */
+       status = -EIO;
        if (clnt->cl_dead) 
-               return -EIO;
+               goto out_release;
 
        flags |= RPC_TASK_ASYNC;
 
        /* Create/initialize a new RPC task */
        status = -ENOMEM;
        if (!(task = rpc_new_task(clnt, flags, tk_ops, data)))
-               goto out;
+               goto out_release;
 
        /* Mask signals on GSS_AUTH upcalls */
        rpc_task_sigmask(task, &oldset);                
                rpc_release_task(task);
 
        rpc_restore_sigmask(&oldset);           
-out:
+       return status;
+out_release:
+       if (tk_ops->rpc_release != NULL)
+               tk_ops->rpc_release(data);
        return status;
 }