tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

proposal for bus_dma(9) change


When bus_dmamap_create() fails, then the map pointer
is undefined. This is IMO a problem, because the
dma free routines in many drivers assume the map
pointer is NULL when invalid.
This let the drivers call bus_dmamap_destroy()
on an invalid map pointer.
Currently, I fixed two drivers: nfe(4) and age(4).

I see two ways to fix this: We go through all
drivers and set the map pointer explicitely
to NULL in the error path of bus_dmamap_create()

*or* we change bus_dma(9) API to define the map pointer
to be NULL when bus_dmamap_create() fails and fix
the bus_dmamap_create() implementation across all ports.

IMO, letting the drivers take care to set the map pointer
to NULL is more error prone since it will surely be often
forgotten by developers when changing or writing/porting
a driver. So personally, I would prefer the bus_dma(9)
API change since this is a "fix-this-once-and-for-all task".



Home | Main Index | Thread Index | Old Index