*s = find_stateid_by_type(cstate->clp, stateid, typemask);
        if (!*s)
                return nfserr_bad_stateid;
+       /* FIXME: move into find_stateid_by_type */
+       atomic_inc(&(*s)->sc_count);
        return nfs_ok;
 }
 
                                NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID,
                                &s, nn);
        if (status)
-               goto out;
+               goto unlock_state;
        status = check_stateid_generation(stateid, &s->sc_stateid, nfsd4_has_session(cstate));
        if (status)
                goto out;
        if (file)
                *filpp = file;
 out:
+       nfs4_put_stid(s);
+unlock_state:
        nfs4_unlock_state();
        return status;
 }
                cstate->replay_owner = stp->st_stateowner;
 
        status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp);
-       if (!status) {
-               /* FIXME: move into find_stateid_by_type */
-               atomic_inc(&stp->st_stid.sc_count);
+       if (!status)
                *stpp = stp;
-       }
+       else
+               nfs4_put_stid(&stp->st_stid);
        return status;
 }
 
        dp = delegstateid(s);
        status = check_stateid_generation(stateid, &dp->dl_stid.sc_stateid, nfsd4_has_session(cstate));
        if (status)
-               goto out;
+               goto put_stateid;
 
        destroy_delegation(dp);
+put_stateid:
+       nfs4_put_stid(&dp->dl_stid);
 out:
        nfs4_unlock_state();