Use M_ZERO flag on malloc when approbiate.
This commit is contained in:
parent
e3b9882dc4
commit
6cf4911dd6
@ -1794,12 +1794,11 @@ ata_init(void)
|
||||
{
|
||||
/* register boot attach to be run when interrupts are enabled */
|
||||
if (!(ata_delayed_attach = (struct intr_config_hook *)
|
||||
malloc(sizeof(struct intr_config_hook),
|
||||
M_TEMP, M_NOWAIT))) {
|
||||
malloc(sizeof(struct intr_config_hook),
|
||||
M_TEMP, M_NOWAIT | M_ZERO))) {
|
||||
printf("ata: malloc of delayed attach hook failed\n");
|
||||
return;
|
||||
}
|
||||
bzero(ata_delayed_attach, sizeof(struct intr_config_hook));
|
||||
|
||||
ata_delayed_attach->ich_func = (void*)ata_boot_attach;
|
||||
if (config_intrhook_establish(ata_delayed_attach) != 0) {
|
||||
|
@ -97,11 +97,10 @@ ad_attach(struct ata_softc *scp, int device)
|
||||
int secsperint;
|
||||
|
||||
|
||||
if (!(adp = malloc(sizeof(struct ad_softc), M_AD, M_NOWAIT))) {
|
||||
if (!(adp = malloc(sizeof(struct ad_softc), M_AD, M_NOWAIT | M_ZERO))) {
|
||||
ata_printf(scp, device, "failed to allocate driver storage\n");
|
||||
return;
|
||||
}
|
||||
bzero(adp, sizeof(struct ad_softc));
|
||||
scp->dev_softc[ATA_DEV(device)] = adp;
|
||||
adp->controller = scp;
|
||||
adp->unit = device;
|
||||
@ -351,13 +350,12 @@ ad_start(struct ad_softc *adp)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(request = malloc(sizeof(struct ad_request), M_AD, M_NOWAIT))) {
|
||||
if (!(request = malloc(sizeof(struct ad_request), M_AD, M_NOWAIT|M_ZERO))) {
|
||||
printf("ad%d: out of memory in start\n", adp->lun);
|
||||
return;
|
||||
}
|
||||
|
||||
/* setup request */
|
||||
bzero(request, sizeof(struct ad_request));
|
||||
request->device = adp;
|
||||
request->bp = bp;
|
||||
request->blockaddr = bp->bio_pblkno;
|
||||
|
@ -183,8 +183,7 @@ arstrategy(struct bio *bp)
|
||||
struct ar_buf *buf1, *buf2;
|
||||
int plba;
|
||||
|
||||
buf1 = malloc(sizeof(struct ar_buf), M_AR, M_NOWAIT);
|
||||
bzero(buf1, sizeof(struct ar_buf));
|
||||
buf1 = malloc(sizeof(struct ar_buf), M_AR, M_NOWAIT | M_ZERO);
|
||||
if (rdp->flags & AR_F_SPAN) {
|
||||
plba = lba;
|
||||
while (plba >= (rdp->subdisk[buf1->drive]->total_secs-rdp->reserved)
|
||||
@ -315,12 +314,12 @@ ar_highpoint_conf(struct ad_softc *adp, struct ar_softc **raidp)
|
||||
for (array = 0; array < 8; array++) {
|
||||
if (!raidp[array]) {
|
||||
raidp[array] =
|
||||
(struct ar_softc*)malloc(sizeof(struct ar_softc),M_AR,M_NOWAIT);
|
||||
(struct ar_softc*)malloc(sizeof(struct ar_softc),M_AR,
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (!raidp[array]) {
|
||||
printf("ar: failed to allocate raid config storage\n");
|
||||
return 1;
|
||||
}
|
||||
bzero(raidp[array], sizeof(struct ar_softc));
|
||||
}
|
||||
raid = raidp[array];
|
||||
|
||||
|
@ -62,11 +62,10 @@ atapi_attach(struct ata_softc *scp, int device)
|
||||
{
|
||||
struct atapi_softc *atp;
|
||||
|
||||
if (!(atp = malloc(sizeof(struct atapi_softc), M_ATAPI, M_NOWAIT))) {
|
||||
if (!(atp = malloc(sizeof(struct atapi_softc), M_ATAPI, M_NOWAIT|M_ZERO))) {
|
||||
ata_printf(scp, device, "failed to allocate driver storage\n");
|
||||
return;
|
||||
}
|
||||
bzero(atp, sizeof(struct atapi_softc));
|
||||
atp->controller = scp;
|
||||
atp->unit = device;
|
||||
if (bootverbose)
|
||||
@ -154,10 +153,10 @@ atapi_queue_cmd(struct atapi_softc *atp, int8_t *ccb, caddr_t data,
|
||||
struct atapi_request *request;
|
||||
int error, s;
|
||||
|
||||
if (!(request = malloc(sizeof(struct atapi_request), M_ATAPI, M_NOWAIT)))
|
||||
if (!(request = malloc(sizeof(struct atapi_request), M_ATAPI,
|
||||
M_NOWAIT | M_ZERO)))
|
||||
return ENOMEM;
|
||||
|
||||
bzero(request, sizeof(struct atapi_request));
|
||||
request->device = atp;
|
||||
request->data = data;
|
||||
request->bytecount = count;
|
||||
|
@ -143,13 +143,12 @@ acdattach(struct atapi_softc *atp)
|
||||
sizeof(struct changer)>>8, sizeof(struct changer),
|
||||
0, 0, 0, 0, 0, 0 };
|
||||
|
||||
chp = malloc(sizeof(struct changer), M_ACD, M_NOWAIT);
|
||||
chp = malloc(sizeof(struct changer), M_ACD, M_NOWAIT | M_ZERO);
|
||||
if (chp == NULL) {
|
||||
printf("acd: out of memory\n");
|
||||
free(cdp, M_ACD);
|
||||
return -1;
|
||||
}
|
||||
bzero(chp, sizeof(struct changer));
|
||||
error = atapi_queue_cmd(cdp->atp, ccb, (caddr_t)chp,
|
||||
sizeof(struct changer),
|
||||
ATPR_F_READ, 60, NULL, NULL);
|
||||
@ -233,9 +232,8 @@ acd_init_lun(struct atapi_softc *atp, struct devstat *stats)
|
||||
{
|
||||
struct acd_softc *cdp;
|
||||
|
||||
if (!(cdp = malloc(sizeof(struct acd_softc), M_ACD, M_NOWAIT)))
|
||||
if (!(cdp = malloc(sizeof(struct acd_softc), M_ACD, M_NOWAIT | M_ZERO)))
|
||||
return NULL;
|
||||
bzero(cdp, sizeof(struct acd_softc));
|
||||
bioq_init(&cdp->bio_queue);
|
||||
cdp->atp = atp;
|
||||
cdp->lun = ata_get_lun(&acd_lun_map);
|
||||
@ -243,11 +241,11 @@ acd_init_lun(struct atapi_softc *atp, struct devstat *stats)
|
||||
cdp->slot = -1;
|
||||
cdp->changer_info = NULL;
|
||||
if (stats == NULL) {
|
||||
if (!(cdp->stats = malloc(sizeof(struct devstat), M_ACD, M_NOWAIT))) {
|
||||
if (!(cdp->stats = malloc(sizeof(struct devstat), M_ACD,
|
||||
M_NOWAIT | M_ZERO))) {
|
||||
free(cdp, M_ACD);
|
||||
return NULL;
|
||||
}
|
||||
bzero(cdp->stats, sizeof(struct devstat));
|
||||
}
|
||||
else
|
||||
cdp->stats = stats;
|
||||
|
@ -84,12 +84,11 @@ afdattach(struct atapi_softc *atp)
|
||||
struct afd_softc *fdp;
|
||||
dev_t dev;
|
||||
|
||||
fdp = malloc(sizeof(struct afd_softc), M_AFD, M_NOWAIT);
|
||||
fdp = malloc(sizeof(struct afd_softc), M_AFD, M_NOWAIT | M_ZERO);
|
||||
if (!fdp) {
|
||||
printf("afd: out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
bzero(fdp, sizeof(struct afd_softc));
|
||||
bioq_init(&fdp->bio_queue);
|
||||
fdp->atp = atp;
|
||||
fdp->lun = ata_get_lun(&afd_lun_map);
|
||||
|
@ -96,12 +96,11 @@ astattach(struct atapi_softc *atp)
|
||||
cdevsw_add(&ast_cdevsw);
|
||||
ast_cdev_done = 1;
|
||||
}
|
||||
stp = malloc(sizeof(struct ast_softc), M_AST, M_NOWAIT);
|
||||
stp = malloc(sizeof(struct ast_softc), M_AST, M_NOWAIT | M_ZERO);
|
||||
if (!stp) {
|
||||
printf("ast: out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
bzero(stp, sizeof(struct ast_softc));
|
||||
bioq_init(&stp->bio_queue);
|
||||
stp->atp = atp;
|
||||
stp->lun = ata_get_lun(&ast_lun_map);
|
||||
|
Loading…
Reference in New Issue
Block a user