From: Jan Klemkow Subject: Re: add missing M_PKTHDR check To: tech@openbsd.org Date: Thu, 14 Aug 2025 21:36:15 +0200 On Tue, Aug 12, 2025 at 08:59:25PM +0200, Jan Klemkow wrote: > In all other archs _bus_dmamap_load_mbuf() checks the M_PKTHDR flag > before using the m_pkthdr struct. The reset of _dm_type and _dm_source should not depend on DIAGNOSTIC. ok? bye, Jan Index: arch/sparc64/sparc64/machdep.c =================================================================== RCS file: /cvs/src/sys/arch/sparc64/sparc64/machdep.c,v diff -u -p -r1.218 machdep.c --- arch/sparc64/sparc64/machdep.c 22 May 2024 05:51:49 -0000 1.218 +++ arch/sparc64/sparc64/machdep.c 14 Aug 2025 19:29:55 -0000 @@ -957,6 +957,11 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, b map->dm_mapsize = 0; map->dm_nsegs = 0; +#ifdef DIAGNOSTIC + if ((m->m_flags & M_PKTHDR) == 0) + panic("_bus_dmamap_load_mbuf: no packet header"); +#endif + if (m->m_pkthdr.len > map->_dm_size) return (EINVAL); @@ -982,9 +987,10 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, b #ifdef DIAGNOSTIC printf("_bus_dmamap_load_mbuf: pmap_extract failed %lx\n", vaddr); +#endif map->_dm_type = 0; map->_dm_source = NULL; -#endif + return EINVAL; } @@ -1014,8 +1020,7 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, b } } - return (bus_dmamap_load_raw(t0, map, segs, i, - (bus_size_t)len, flags)); + return (bus_dmamap_load_raw(t0, map, segs, i, (bus_size_t)len, flags)); } /*