Make malloc use M_ZERO in some more locations.
Don't check for a null pointer if malloc called with M_WAITOK. Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net> Approved by: bp
This commit is contained in:
parent
8cfaee4a94
commit
e401b83c31
@ -163,14 +163,13 @@ rescan:
|
||||
* might cause a bogus v_data pointer to get dereferenced
|
||||
* elsewhere if MALLOC should block.
|
||||
*/
|
||||
MALLOC(np, struct nwnode *, sizeof *np, M_NWNODE, M_WAITOK);
|
||||
MALLOC(np, struct nwnode *, sizeof *np, M_NWNODE, M_WAITOK | M_ZERO);
|
||||
error = getnewvnode(VT_NWFS, mp, nwfs_vnodeop_p, &vp);
|
||||
if (error) {
|
||||
*vpp = NULL;
|
||||
FREE(np, M_NWNODE);
|
||||
return (error);
|
||||
}
|
||||
bzero(np, sizeof(*np));
|
||||
vp->v_data = np;
|
||||
np->n_vnode = vp;
|
||||
np->n_mount = nmp;
|
||||
|
@ -125,7 +125,6 @@ nwfs_initnls(struct nwmount *nmp) {
|
||||
return 0;
|
||||
}
|
||||
MALLOC(pe, char *, 256 * 4, M_NWFSDATA, M_WAITOK);
|
||||
if (pe == NULL) return ENOMEM;
|
||||
pc = pe;
|
||||
do {
|
||||
COPY_TABLE(nmp->m.nls.to_lower, ncp_defnls.to_lower);
|
||||
@ -183,13 +182,12 @@ static int nwfs_mount(struct mount *mp, char *path, caddr_t data,
|
||||
ncp_conn_unlock(conn,p); /* we keep the ref */
|
||||
mp->mnt_stat.f_iosize = conn->buffer_size;
|
||||
/* We must malloc our own mount info */
|
||||
MALLOC(nmp,struct nwmount *,sizeof(struct nwmount),M_NWFSDATA,M_USE_RESERVE);
|
||||
MALLOC(nmp,struct nwmount *,sizeof(struct nwmount),M_NWFSDATA,M_USE_RESERVE | M_ZERO);
|
||||
if (nmp == NULL) {
|
||||
nwfs_printf("could not alloc nwmount\n");
|
||||
error = ENOMEM;
|
||||
goto bad;
|
||||
}
|
||||
bzero(nmp,sizeof(*nmp));
|
||||
mp->mnt_data = (qaddr_t)nmp;
|
||||
nmp->connh = handle;
|
||||
nmp->n_root = NULL;
|
||||
|
@ -189,10 +189,8 @@ ncp_conn_alloc(struct proc *p, struct ucred *cred, struct ncp_conn **conn)
|
||||
struct ncp_conn *ncp;
|
||||
|
||||
MALLOC(ncp, struct ncp_conn *, sizeof(struct ncp_conn),
|
||||
M_NCPDATA, M_WAITOK);
|
||||
if (ncp == NULL) return ENOMEM;
|
||||
M_NCPDATA, M_WAITOK | M_ZERO);
|
||||
error = 0;
|
||||
bzero(ncp,sizeof(*ncp));
|
||||
lockinit(&ncp->nc_lock, PZERO, "ncplck", 0, 0);
|
||||
ncp_conn_cnt++;
|
||||
ncp->nc_id = ncp_next_ref++;
|
||||
@ -413,9 +411,8 @@ ncp_conn_gethandle(struct ncp_conn *conn, struct proc *p, struct ncp_handle **ha
|
||||
lockmgr(&lhlock, LK_RELEASE, 0, p);
|
||||
return 0;
|
||||
}
|
||||
MALLOC(refp,struct ncp_handle *,sizeof(struct ncp_handle),M_NCPDATA,M_WAITOK);
|
||||
if (refp == NULL) return ENOMEM;
|
||||
bzero(refp,sizeof(*refp));
|
||||
MALLOC(refp,struct ncp_handle *,sizeof(struct ncp_handle),M_NCPDATA,
|
||||
M_WAITOK | M_ZERO);
|
||||
SLIST_INSERT_HEAD(&lhlist,refp,nh_next);
|
||||
refp->nh_ref++;
|
||||
refp->nh_proc = p;
|
||||
|
@ -163,14 +163,13 @@ rescan:
|
||||
* might cause a bogus v_data pointer to get dereferenced
|
||||
* elsewhere if MALLOC should block.
|
||||
*/
|
||||
MALLOC(np, struct nwnode *, sizeof *np, M_NWNODE, M_WAITOK);
|
||||
MALLOC(np, struct nwnode *, sizeof *np, M_NWNODE, M_WAITOK | M_ZERO);
|
||||
error = getnewvnode(VT_NWFS, mp, nwfs_vnodeop_p, &vp);
|
||||
if (error) {
|
||||
*vpp = NULL;
|
||||
FREE(np, M_NWNODE);
|
||||
return (error);
|
||||
}
|
||||
bzero(np, sizeof(*np));
|
||||
vp->v_data = np;
|
||||
np->n_vnode = vp;
|
||||
np->n_mount = nmp;
|
||||
|
@ -125,7 +125,6 @@ nwfs_initnls(struct nwmount *nmp) {
|
||||
return 0;
|
||||
}
|
||||
MALLOC(pe, char *, 256 * 4, M_NWFSDATA, M_WAITOK);
|
||||
if (pe == NULL) return ENOMEM;
|
||||
pc = pe;
|
||||
do {
|
||||
COPY_TABLE(nmp->m.nls.to_lower, ncp_defnls.to_lower);
|
||||
@ -183,13 +182,12 @@ static int nwfs_mount(struct mount *mp, char *path, caddr_t data,
|
||||
ncp_conn_unlock(conn,p); /* we keep the ref */
|
||||
mp->mnt_stat.f_iosize = conn->buffer_size;
|
||||
/* We must malloc our own mount info */
|
||||
MALLOC(nmp,struct nwmount *,sizeof(struct nwmount),M_NWFSDATA,M_USE_RESERVE);
|
||||
MALLOC(nmp,struct nwmount *,sizeof(struct nwmount),M_NWFSDATA,M_USE_RESERVE | M_ZERO);
|
||||
if (nmp == NULL) {
|
||||
nwfs_printf("could not alloc nwmount\n");
|
||||
error = ENOMEM;
|
||||
goto bad;
|
||||
}
|
||||
bzero(nmp,sizeof(*nmp));
|
||||
mp->mnt_data = (qaddr_t)nmp;
|
||||
nmp->connh = handle;
|
||||
nmp->n_root = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user