missing M_ZERO malloc flag in src/sys/arm/arm/busdma_machdep.c

fate fate10 at gmail.com
Tue May 15 01:09:10 UTC 2007


Hi,
It would be good to apply this small patch:

*** busdma_machdep.c.orig
--- busdma_machdep.c
***************
*** 345,351 ****
        if (!parent)
                parent = arm_root_dma_tag;

!       newtag = (bus_dma_tag_t)malloc(sizeof(*newtag), M_DEVBUF, M_NOWAIT);
        if (newtag == NULL) {
                CTR4(KTR_BUSDMA, "%s returned tag %p tag flags 0x%x error %d",
                    __func__, newtag, 0, error);
--- 345,351 ----
        if (!parent)
                parent = arm_root_dma_tag;

!       newtag = (bus_dma_tag_t)malloc(sizeof(*newtag), M_DEVBUF,
M_NOWAIT | M_ZERO);
        if (newtag == NULL) {
                CTR4(KTR_BUSDMA, "%s returned tag %p tag flags 0x%x error %d",
                    __func__, newtag, 0, error);

or the structure newtag would not be initialized correctly in case of
dirty memory and failed on this if block:

		if (dmat->bounce_zone == NULL) {
			if ((error = alloc_bounce_zone(dmat)) != 0) {
				_busdma_free_dmamap(newmap);
				*mapp = NULL;
				return (error);
			}
		}

left bounce_zone unallocated with kernel crash as result

SY, Vladimir Belian


More information about the freebsd-arm mailing list