Skip to contentSkip to conversation

blkmapd: fix NULL dereference in bl_add_disk

PATCH New Alexandra Diupina 1 participant 1 message Dec 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blkmapd: fix NULL dereference in bl_add_disk

Check serial and disk->serial for NULL before comparing to prevent NULL pointer dereferencing.

Fixes 6b9d7ab4 ("blkmapd: Add complex block layout discovery and mapping daemon")
---
 utils/blkmapd/device-discovery.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
utils/blkmapd/device-discovery.c +2 -1
index a565fdbd..221b14c5 100644
@@ -179,7 +179,8 @@ static void bl_add_disk(char *filepath)
 		/* Already scanned or a partition?
 		 * XXX: if released each time, maybe not need to compare
 		 */
-		if ((serial->len == disk->serial->len) &&
+		if (serial && disk->serial &&
+			(serial->len == disk->serial->len) &&
 		    !memcmp(serial->data, disk->serial->data, serial->len)) {
 			diskpath = bl_get_path(filepath, disk->paths);
 			break;
Signature · 1 line
2.30.2