[PATCH] dma-debug: Avoid NULL dereference when checking sync
From: Maarten ter Huurne
Date: Sun Feb 28 2016 - 10:30:25 EST
check_sync() calls bucket_find_contain(), which in turn calls
dma_get_max_seg_size(), which dereferences the device pointer.
Signed-off-by: Maarten ter Huurne <maarten@xxxxxxxxxxxxxx>
---
lib/dma-debug.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 4a1515f..4960402 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -1194,6 +1194,13 @@ static void check_sync(struct device *dev,
struct hash_bucket *bucket;
unsigned long flags;
+ if (!ref->dev) {
+ err_printk(dev, NULL, "DMA-API: device driver passes NULL "
+ "for device to DMA sync function; "
+ "cannot check usage\n");
+ return;
+ }
+
bucket = get_hash_bucket(ref, &flags);
entry = bucket_find_contain(&bucket, ref, &flags);
--
2.6.2