mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 212/212] dma: make dma_mapping_error NULL-device safe
@ 2026-06-19 16:09 Johannes Schneider
  0 siblings, 0 replies; only message in thread
From: Johannes Schneider @ 2026-06-19 16:09 UTC (permalink / raw)
  To: barebox; +Cc: Johannes Schneider

PBL callers often pass NULL as dev; NULL deref of dev->dma_mask
reads i.MX8M boot ROM and returns junk byte causing false 'mapping
error'. Treat NULL dev as 'no constraint'.

Assisted-by: Claude:claude-opus-4-7
Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
---
 include/dma.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/dma.h b/include/dma.h
index b8016c2e89..60937a69aa 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -69,8 +69,11 @@ static inline void dma_set_mask(struct device *dev, u64 dma_mask)
 
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
-	return dma_addr == DMA_ERROR_CODE ||
-		(dev->dma_mask && dma_addr > dev->dma_mask);
+	if (dma_addr == DMA_ERROR_CODE)
+		return 1;
+	if (!dev)
+		return 0;
+	return dev->dma_mask && dma_addr > dev->dma_mask;
 }
 
 static inline dma_addr_t cpu_to_dma(struct device *dev, void *cpu_addr)
-- 
2.43.0




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-19 16:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-19 16:09 [PATCH 212/212] dma: make dma_mapping_error NULL-device safe Johannes Schneider

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox