Skip to contentSkip to conversation

dma-debug: Avoid NULL dereference when checking sync

PATCH New Maarten ter Huurne 1 participant 1 message Feb 28, 2016 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-debug: Avoid NULL dereference when checking sync

check_sync() calls bucket_find_contain(), which in turn calls dma_get_max_seg_size(), which dereferences the device pointer.

---
 lib/dma-debug.c | 7 +++++++
 1 file changed, 7 insertions(+)
lib/dma-debug.c +7 -0
index 4a1515f..4960402 100644
@@ -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);
Signature · 1 line
2.6.2