Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/nfs MALLOC()/FREE() are not to be used for variable size...
details: https://anonhg.NetBSD.org/src/rev/388cbdb54bfd
branches: trunk
changeset: 495703:388cbdb54bfd
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Aug 03 06:15:02 2000 +0000
description:
MALLOC()/FREE() are not to be used for variable size allocations.
diffstat:
sys/nfs/nfs_node.c | 6 +++---
sys/nfs/nfs_serv.c | 49 +++++++++++++++++++++++--------------------------
sys/nfs/nfs_subs.c | 6 +++---
sys/nfs/nfs_vnops.c | 5 ++---
4 files changed, 31 insertions(+), 35 deletions(-)
diffs (248 lines):
diff -r b9204f95b614 -r 388cbdb54bfd sys/nfs/nfs_node.c
--- a/sys/nfs/nfs_node.c Thu Aug 03 05:04:02 2000 +0000
+++ b/sys/nfs/nfs_node.c Thu Aug 03 06:15:02 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_node.c,v 1.33 2000/03/30 12:51:14 augustss Exp $ */
+/* $NetBSD: nfs_node.c,v 1.34 2000/08/03 06:15:02 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -165,7 +165,7 @@
*/
LIST_INSERT_HEAD(nhpp, np, n_hash);
if (fhsize > NFS_SMALLFH) {
- MALLOC(np->n_fhp, nfsfh_t *, fhsize, M_NFSBIGFH, M_WAITOK);
+ np->n_fhp = malloc(fhsize, M_NFSBIGFH, M_WAITOK);
} else
np->n_fhp = &np->n_fh;
memcpy((caddr_t)np->n_fhp, (caddr_t)fhp, fhsize);
@@ -269,7 +269,7 @@
FREE(np->n_dircache, M_NFSDIROFF);
}
if (np->n_fhsize > NFS_SMALLFH) {
- FREE((caddr_t)np->n_fhp, M_NFSBIGFH);
+ free((caddr_t)np->n_fhp, M_NFSBIGFH);
}
pool_put(&nfs_vattr_pool, np->n_vattr);
diff -r b9204f95b614 -r 388cbdb54bfd sys/nfs/nfs_serv.c
--- a/sys/nfs/nfs_serv.c Thu Aug 03 05:04:02 2000 +0000
+++ b/sys/nfs/nfs_serv.c Thu Aug 03 06:15:02 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_serv.c,v 1.55 2000/06/27 17:52:32 mrg Exp $ */
+/* $NetBSD: nfs_serv.c,v 1.56 2000/08/03 06:15:03 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -670,8 +670,7 @@
m2 = m;
}
}
- MALLOC(iv, struct iovec *, i * sizeof (struct iovec),
- M_TEMP, M_WAITOK);
+ iv = malloc(i * sizeof (struct iovec), M_TEMP, M_WAITOK);
uiop->uio_iov = iv2 = iv;
m = mb;
left = cnt;
@@ -697,7 +696,7 @@
uiop->uio_segflg = UIO_SYSSPACE;
error = VOP_READ(vp, uiop, IO_NODELOCKED, cred);
off = uiop->uio_offset;
- FREE((caddr_t)iv2, M_TEMP);
+ free((caddr_t)iv2, M_TEMP);
if (error || (getret = VOP_GETATTR(vp, &va, cred, procp)) != 0){
if (!error)
error = getret;
@@ -844,8 +843,7 @@
}
if (len > 0) {
- MALLOC(ivp, struct iovec *, cnt * sizeof (struct iovec), M_TEMP,
- M_WAITOK);
+ ivp = malloc(cnt * sizeof (struct iovec), M_TEMP, M_WAITOK);
uiop->uio_iov = iv = ivp;
uiop->uio_iovcnt = cnt;
mp = mrep;
@@ -878,7 +876,7 @@
uiop->uio_offset = off;
error = VOP_WRITE(vp, uiop, ioflags, cred);
nfsstats.srvvop_writes++;
- FREE((caddr_t)iv, M_TEMP);
+ free((caddr_t)iv, M_TEMP);
}
aftat_ret = VOP_GETATTR(vp, &va, cred, procp);
vput(vp);
@@ -1123,8 +1121,7 @@
mp = mp->m_next;
}
uiop->uio_iovcnt = i;
- MALLOC(iov, struct iovec *, i * sizeof (struct iovec),
- M_TEMP, M_WAITOK);
+ iov = malloc(i * sizeof (struct iovec), M_TEMP, M_WAITOK);
uiop->uio_iov = ivp = iov;
mp = mrep;
while (mp) {
@@ -1139,7 +1136,7 @@
error = VOP_WRITE(vp, uiop, ioflags, cred);
nfsstats.srvvop_writes++;
}
- FREE((caddr_t)iov, M_TEMP);
+ free((caddr_t)iov, M_TEMP);
}
m_freem(mrep);
if (vp) {
@@ -2117,7 +2114,7 @@
if (v3)
nfsm_srvsattr(&va);
nfsm_strsiz(len2, NFS_MAXPATHLEN);
- MALLOC(pathcp, caddr_t, len2 + 1, M_TEMP, M_WAITOK);
+ pathcp = malloc(len2 + 1, M_TEMP, M_WAITOK);
iv.iov_base = pathcp;
iv.iov_len = len2;
io.uio_resid = len2;
@@ -2172,7 +2169,7 @@
}
out:
if (pathcp)
- FREE(pathcp, M_TEMP);
+ free(pathcp, M_TEMP);
if (dirp) {
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
vrele(dirp);
@@ -2201,7 +2198,7 @@
if (nd.ni_vp)
vrele(nd.ni_vp);
if (pathcp)
- FREE(pathcp, M_TEMP);
+ free(pathcp, M_TEMP);
return (error);
}
@@ -2537,7 +2534,7 @@
return (0);
}
VOP_UNLOCK(vp, 0);
- MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK);
+ rbuf = malloc(siz, M_TEMP, M_WAITOK);
again:
iv.iov_base = rbuf;
iv.iov_len = fullsiz;
@@ -2565,7 +2562,7 @@
VOP_UNLOCK(vp, 0);
if (error) {
vrele(vp);
- FREE((caddr_t)rbuf, M_TEMP);
+ free((caddr_t)rbuf, M_TEMP);
if (cookies)
free((caddr_t)cookies, M_TEMP);
nfsm_reply(NFSX_POSTOPATTR(v3));
@@ -2592,8 +2589,8 @@
nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
*tl++ = nfs_false;
*tl = nfs_true;
- FREE((caddr_t)rbuf, M_TEMP);
- FREE((caddr_t)cookies, M_TEMP);
+ free((caddr_t)rbuf, M_TEMP);
+ free((caddr_t)cookies, M_TEMP);
return (0);
}
}
@@ -2712,8 +2709,8 @@
mp->m_len = bp - mtod(mp, caddr_t);
} else
mp->m_len += bp - bpos;
- FREE((caddr_t)rbuf, M_TEMP);
- FREE((caddr_t)cookies, M_TEMP);
+ free((caddr_t)rbuf, M_TEMP);
+ free((caddr_t)cookies, M_TEMP);
nfsm_srvdone;
}
@@ -2796,7 +2793,7 @@
}
VOP_UNLOCK(vp, 0);
- MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK);
+ rbuf = malloc(siz, M_TEMP, M_WAITOK);
again:
iv.iov_base = rbuf;
iv.iov_len = fullsiz;
@@ -2840,8 +2837,8 @@
if (error) {
vrele(vp);
if (cookies)
- FREE((caddr_t)cookies, M_TEMP);
- FREE((caddr_t)rbuf, M_TEMP);
+ free((caddr_t)cookies, M_TEMP);
+ free((caddr_t)rbuf, M_TEMP);
nfsm_reply(NFSX_V3POSTOPATTR);
nfsm_srvpostop_attr(getret, &at);
return (0);
@@ -2863,8 +2860,8 @@
tl += 2;
*tl++ = nfs_false;
*tl = nfs_true;
- FREE((caddr_t)cookies, M_TEMP);
- FREE((caddr_t)rbuf, M_TEMP);
+ free((caddr_t)cookies, M_TEMP);
+ free((caddr_t)rbuf, M_TEMP);
return (0);
}
}
@@ -3021,8 +3018,8 @@
mp->m_len = bp - mtod(mp, caddr_t);
} else
mp->m_len += bp - bpos;
- FREE((caddr_t)cookies, M_TEMP);
- FREE((caddr_t)rbuf, M_TEMP);
+ free((caddr_t)cookies, M_TEMP);
+ free((caddr_t)rbuf, M_TEMP);
nfsm_srvdone;
}
diff -r b9204f95b614 -r 388cbdb54bfd sys/nfs/nfs_subs.c
--- a/sys/nfs/nfs_subs.c Thu Aug 03 05:04:02 2000 +0000
+++ b/sys/nfs/nfs_subs.c Thu Aug 03 06:15:02 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_subs.c,v 1.79 2000/06/28 03:30:42 mrg Exp $ */
+/* $NetBSD: nfs_subs.c,v 1.80 2000/08/03 06:15:05 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -1750,7 +1750,7 @@
if (error || len == 0) {
FREE(buf, M_TEMP);
if (cookies)
- FREE(cookies, M_TEMP);
+ free(cookies, M_TEMP);
return;
}
@@ -1774,7 +1774,7 @@
}
FREE(buf, M_TEMP);
- FREE(cookies, M_TEMP);
+ free(cookies, M_TEMP);
}
#endif /* NFS */
diff -r b9204f95b614 -r 388cbdb54bfd sys/nfs/nfs_vnops.c
--- a/sys/nfs/nfs_vnops.c Thu Aug 03 05:04:02 2000 +0000
+++ b/sys/nfs/nfs_vnops.c Thu Aug 03 06:15:02 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_vnops.c,v 1.115 2000/07/22 15:26:14 jdolecek Exp $ */
+/* $NetBSD: nfs_vnops.c,v 1.116 2000/08/03 06:15:06 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -1961,8 +1961,7 @@
if (!error && ap->a_cookies) {
ncookies = count / 16;
- MALLOC(cookies, off_t *, sizeof (off_t) * ncookies, M_TEMP,
- M_WAITOK);
+ cookies = malloc(sizeof (off_t) * ncookies, M_TEMP, M_WAITOK);
*ap->a_cookies = cookies;
}
Home |
Main Index |
Thread Index |
Old Index