[PATCH] dm-verity: fix a possible NULL pointer dereference

Mikulas Patocka <[email protected]> Thu, 9 Jul 2026 21:35:06 +0200 (CEST)
Newsgroups dev.linux.lists.dm-devel
Message-ID <[email protected]>
Fix a possible NULL pointer dereference dm_verity_loadpin_is_bdev_trusted
if the device has no table.

Signed-off-by: Mikulas Patocka <[email protected]>
Assisted-by: Claude:claude-opus-4-6
Fixes: b6c1c5745ccc ("dm: Add verity helpers for LoadPin")
Cc: [email protected]

---
 drivers/md/dm-verity-loadpin.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/drivers/md/dm-verity-loadpin.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-verity-loadpin.c	2023-09-05 14:45:58.000000000 +0200
+++ linux-2.6/drivers/md/dm-verity-loadpin.c	2026-07-01 13:24:12.000000000 +0200
@@ -70,7 +70,7 @@ bool dm_verity_loadpin_is_bdev_trusted(s
 
 	table = dm_get_live_table(md, &srcu_idx);
 
-	if (table->num_targets != 1)
+	if (!table || table->num_targets != 1)
 		goto out;
 
 	ti = dm_table_get_target(table, 0);