summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBret Lambert <blambert@cvs.openbsd.org>2009-06-06 02:23:34 +0000
committerBret Lambert <blambert@cvs.openbsd.org>2009-06-06 02:23:34 +0000
commitb5f0d3f757a0633af4b1d3e18294583874336c2f (patch)
treebbf61fe88a0d3b3b4e6b49fa3e3b6e5198b75da2
parente30123f62cefd11d5df4928fb56d398c7d671bac (diff)
Consolidate error handling code. Much less atrocious than before.
"get it in" thib@
-rw-r--r--sys/nfs/nfs_serv.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c
index d70aebd0d5a..0f0a6f8f35b 100644
--- a/sys/nfs/nfs_serv.c
+++ b/sys/nfs/nfs_serv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_serv.c,v 1.72 2009/06/05 21:35:33 thib Exp $ */
+/* $OpenBSD: nfs_serv.c,v 1.73 2009/06/06 02:23:33 blambert Exp $ */
/* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */
/*
@@ -756,16 +756,11 @@ nfsrv_write(nfsd, slp, procp, mrq)
}
if (len > NFS_MAXDATA || len < 0 || i < len) {
error = EIO;
- nfsm_reply(2 * NFSX_UNSIGNED);
- nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, &mb);
- return (0);
+ goto bad;
}
error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly);
- if (error) {
- nfsm_reply(2 * NFSX_UNSIGNED);
- nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, &mb);
- return (0);
- }
+ if (error)
+ goto bad;
if (v3)
forat_ret = VOP_GETATTR(vp, &forat, cred, procp);
if (vp->v_type != VREG) {
@@ -773,16 +768,11 @@ nfsrv_write(nfsd, slp, procp, mrq)
error = EINVAL;
else
error = (vp->v_type == VDIR) ? EISDIR : EACCES;
+ goto vbad;
}
- if (!error) {
- error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1);
- }
- if (error) {
- vput(vp);
- nfsm_reply(NFSX_WCCDATA(v3));
- nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, &mb);
- return (0);
- }
+ error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1);
+ if (error)
+ goto vbad;
if (len > 0) {
ivp = malloc(cnt * sizeof(struct iovec), M_TEMP, M_WAITOK);
@@ -842,6 +832,13 @@ nfsrv_write(nfsd, slp, procp, mrq)
}
nfsmout:
return(error);
+
+vbad:
+ vput(vp);
+bad:
+ nfsm_reply(0);
+ nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, &mb);
+ return (0);
}
/*