dm table: fix potential NULL pointer in dm_table_set_integrity
PATCH 1/1 dm table: fix potential NULL pointer in dm_table_set_integrity
Commit a63a5cf (dm: improve block integrity support) introduced a two-phase initialization of a DM device's integrity profile. The dm_table_set_integrity() call to blk_integrity_register() may deference a NULL 'template_disk' due to an integrity profile mismatch.
An integrity profile mismatch can occur if the integrity profile for devices in a DM table are changed between the call to dm_table_prealloc_integrity() and dm_table_set_integrity() (possible via table loads for stacked DM devices with integrity profiles).
Signed-off-by Mike Snitzer <[email protected]>
Cc [email protected] # >= 2.6.39.y
--- drivers/md/dm-table.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
drivers/md/dm-table.c +7 -6
@@ -1260,14 +1260,15 @@ static void dm_table_set_integrity(struct dm_table *t)return ; template_disk =dm_table_get_integrity_disk (t, true); -if (!template_disk && -blk_integrity_is_initialized (dm_disk (t->md))) { +if (template_disk) +blk_integrity_register (dm_disk (t->md), +blk_get_integrity (template_disk)); +else if (blk_integrity_is_initialized (dm_disk (t->md)))DMWARN ("%s: device no longer has a valid integrity profile" ,dm_device_name (t->md)); -return ; - } -blk_integrity_register (dm_disk (t->md), -blk_get_integrity (template_disk)); +else +DMWARN ("%s: unable to establish an integrity profile" , +dm_device_name (t->md)); } void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
Signature · 1 line
1.7.4.4