mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 14:48:57 +00:00
Add the use of M_ZERO to some malloc calls.
Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net> Approved by: gibbs
This commit is contained in:
parent
1c2598aa2e
commit
5417ec4db1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=67888
@ -1349,13 +1349,12 @@ xpt_init(dummy)
|
||||
*/
|
||||
xpt_config_hook =
|
||||
(struct intr_config_hook *)malloc(sizeof(struct intr_config_hook),
|
||||
M_TEMP, M_NOWAIT);
|
||||
M_TEMP, M_NOWAIT | M_ZERO);
|
||||
if (xpt_config_hook == NULL) {
|
||||
printf("xpt_init: Cannot malloc config hook "
|
||||
"- failing attach\n");
|
||||
return;
|
||||
}
|
||||
bzero(xpt_config_hook, sizeof(*xpt_config_hook));
|
||||
|
||||
xpt_config_hook->ich_func = xpt_config;
|
||||
if (config_intrhook_establish(xpt_config_hook) != 0) {
|
||||
@ -5406,10 +5405,10 @@ probestart(struct cam_periph *periph, union ccb *start_ccb)
|
||||
|
||||
if ((device->quirk->quirks & CAM_QUIRK_NOSERIAL) == 0)
|
||||
serial_buf = (struct scsi_vpd_unit_serial_number *)
|
||||
malloc(sizeof(*serial_buf), M_TEMP, M_NOWAIT);
|
||||
malloc(sizeof(*serial_buf), M_TEMP,
|
||||
M_NOWAIT | M_ZERO);
|
||||
|
||||
if (serial_buf != NULL) {
|
||||
bzero(serial_buf, sizeof(*serial_buf));
|
||||
scsi_inquiry(csio,
|
||||
/*retries*/4,
|
||||
probedone,
|
||||
|
@ -3030,8 +3030,7 @@ cdreportkey(struct cam_periph *periph, struct dvd_authinfo *authinfo)
|
||||
}
|
||||
|
||||
if (length != 0) {
|
||||
databuf = malloc(length, M_DEVBUF, M_WAITOK);
|
||||
bzero(databuf, length);
|
||||
databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
} else
|
||||
databuf = NULL;
|
||||
|
||||
@ -3162,12 +3161,10 @@ cdsendkey(struct cam_periph *periph, struct dvd_authinfo *authinfo)
|
||||
|
||||
length = sizeof(*challenge_data);
|
||||
|
||||
challenge_data = malloc(length, M_DEVBUF, M_WAITOK);
|
||||
challenge_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
|
||||
databuf = (u_int8_t *)challenge_data;
|
||||
|
||||
bzero(databuf, length);
|
||||
|
||||
scsi_ulto2b(length - sizeof(challenge_data->data_len),
|
||||
challenge_data->data_len);
|
||||
|
||||
@ -3181,12 +3178,10 @@ cdsendkey(struct cam_periph *periph, struct dvd_authinfo *authinfo)
|
||||
|
||||
length = sizeof(*key2_data);
|
||||
|
||||
key2_data = malloc(length, M_DEVBUF, M_WAITOK);
|
||||
key2_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
|
||||
databuf = (u_int8_t *)key2_data;
|
||||
|
||||
bzero(databuf, length);
|
||||
|
||||
scsi_ulto2b(length - sizeof(key2_data->data_len),
|
||||
key2_data->data_len);
|
||||
|
||||
@ -3200,12 +3195,10 @@ cdsendkey(struct cam_periph *periph, struct dvd_authinfo *authinfo)
|
||||
|
||||
length = sizeof(*rpc_data);
|
||||
|
||||
rpc_data = malloc(length, M_DEVBUF, M_WAITOK);
|
||||
rpc_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
|
||||
databuf = (u_int8_t *)rpc_data;
|
||||
|
||||
bzero(databuf, length);
|
||||
|
||||
scsi_ulto2b(length - sizeof(rpc_data->data_len),
|
||||
rpc_data->data_len);
|
||||
|
||||
@ -3347,8 +3340,7 @@ cdreaddvdstructure(struct cam_periph *periph, struct dvd_struct *dvdstruct)
|
||||
}
|
||||
|
||||
if (length != 0) {
|
||||
databuf = malloc(length, M_DEVBUF, M_WAITOK);
|
||||
bzero(databuf, length);
|
||||
databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
} else
|
||||
databuf = NULL;
|
||||
|
||||
|
@ -1192,8 +1192,7 @@ chgetelemstatus(struct cam_periph *periph,
|
||||
|
||||
user_data = (struct changer_element_status *)
|
||||
malloc(avail * sizeof(struct changer_element_status),
|
||||
M_DEVBUF, M_WAITOK);
|
||||
bzero(user_data, avail * sizeof(struct changer_element_status));
|
||||
M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
|
||||
desc = (struct read_element_status_descriptor *)((uintptr_t)data +
|
||||
sizeof(struct read_element_status_header) +
|
||||
|
@ -824,12 +824,11 @@ adw_alloc(device_t dev, struct resource *regs, int regs_type, int regs_id)
|
||||
/*
|
||||
* Allocate a storage area for us
|
||||
*/
|
||||
adw = malloc(sizeof(struct adw_softc), M_DEVBUF, M_NOWAIT);
|
||||
adw = malloc(sizeof(struct adw_softc), M_DEVBUF, M_NOWAIT | M_ZERO);
|
||||
if (adw == NULL) {
|
||||
printf("adw%d: cannot malloc!\n", device_get_unit(dev));
|
||||
return NULL;
|
||||
}
|
||||
bzero(adw, sizeof(struct adw_softc));
|
||||
LIST_INIT(&adw->pending_ccbs);
|
||||
SLIST_INIT(&adw->sg_maps);
|
||||
adw->device = dev;
|
||||
|
@ -393,12 +393,11 @@ ahballoc(u_long unit, struct resource *res)
|
||||
/*
|
||||
* Allocate a storage area for us
|
||||
*/
|
||||
ahb = malloc(sizeof(struct ahb_softc), M_DEVBUF, M_NOWAIT);
|
||||
ahb = malloc(sizeof(struct ahb_softc), M_DEVBUF, M_NOWAIT | M_ZERO);
|
||||
if (!ahb) {
|
||||
printf("ahb%ld: cannot malloc!\n", unit);
|
||||
return (NULL);
|
||||
}
|
||||
bzero(ahb, sizeof(struct ahb_softc));
|
||||
SLIST_INIT(&ahb->free_ecbs);
|
||||
LIST_INIT(&ahb->pending_ccbs);
|
||||
ahb->unit = unit;
|
||||
|
@ -1795,11 +1795,10 @@ ahc_platform_set_tags(struct ahc_softc *ahc,
|
||||
int
|
||||
ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg)
|
||||
{
|
||||
ahc->platform_data =
|
||||
malloc(sizeof(struct ahc_platform_data), M_DEVBUF, M_NOWAIT);
|
||||
ahc->platform_data = malloc(sizeof(struct ahc_platform_data), M_DEVBUF,
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (ahc->platform_data == NULL)
|
||||
return (ENOMEM);
|
||||
memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1795,11 +1795,10 @@ ahc_platform_set_tags(struct ahc_softc *ahc,
|
||||
int
|
||||
ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg)
|
||||
{
|
||||
ahc->platform_data =
|
||||
malloc(sizeof(struct ahc_platform_data), M_DEVBUF, M_NOWAIT);
|
||||
ahc->platform_data = malloc(sizeof(struct ahc_platform_data), M_DEVBUF,
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (ahc->platform_data == NULL)
|
||||
return (ENOMEM);
|
||||
memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user