Commit 876fbba1 authored by Mike Snitzer's avatar Mike Snitzer Committed by Alasdair G Kergon

dm table: avoid crash if integrity profile changes

Commit a63a5cf8 (dm: improve block integrity support) introduced a
two-phase initialization of a DM device's integrity profile.  This
patch avoids dereferencing a NULL 'template_disk' pointer in
blk_integrity_register() if there is an integrity profile mismatch in
dm_table_set_integrity().

This can occur if the integrity profiles for stacked devices in a DM
table are changed between the call to dm_table_prealloc_integrity() and
dm_table_set_integrity().
Reported-by: default avatarZdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
Cc: stable@kernel.org # 2.6.39
parent 68e58a29
...@@ -1238,14 +1238,15 @@ static void dm_table_set_integrity(struct dm_table *t) ...@@ -1238,14 +1238,15 @@ static void dm_table_set_integrity(struct dm_table *t)
return; return;
template_disk = dm_table_get_integrity_disk(t, true); template_disk = dm_table_get_integrity_disk(t, true);
if (!template_disk && if (template_disk)
blk_integrity_is_initialized(dm_disk(t->md))) { 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", DMWARN("%s: device no longer has a valid integrity profile",
dm_device_name(t->md)); dm_device_name(t->md));
return; else
} DMWARN("%s: unable to establish an integrity profile",
blk_integrity_register(dm_disk(t->md), dm_device_name(t->md));
blk_get_integrity(template_disk));
} }
static int device_flush_capable(struct dm_target *ti, struct dm_dev *dev, static int device_flush_capable(struct dm_target *ti, struct dm_dev *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment