summaryrefslogtreecommitdiff
path: root/lib/cache_segtype
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2015-05-07 14:04:22 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2015-05-08 15:15:11 +0200
commitcbdf514bbc3f22453c2c72c913e9161935a22bd8 (patch)
tree75aa425613f65caf9c4d5994311fe6cc6269c1cc /lib/cache_segtype
parent29c709f5914ccd9159d84f8920c34b2c6ef51740 (diff)
downloadlvm2-cbdf514bbc3f22453c2c72c913e9161935a22bd8.tar.gz
debug: extra validation of passed segment
Always check if passed segment really is correct cache segment. (Avoids derefernce of possibly NULL seg->pool_lv).
Diffstat (limited to 'lib/cache_segtype')
-rw-r--r--lib/cache_segtype/cache.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index afc0ec64c..ca30495aa 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -282,9 +282,16 @@ static int _cache_add_target_line(struct dev_manager *dm,
struct dm_tree_node *node, uint64_t len,
uint32_t *pvmove_mirror_count __attribute__((unused)))
{
- struct lv_segment *cache_pool_seg = first_seg(seg->pool_lv);
+ struct lv_segment *cache_pool_seg;
char *metadata_uuid, *data_uuid, *origin_uuid;
+ if (!seg->pool_lv || !seg_is_cache(seg)) {
+ log_error(INTERNAL_ERROR "Passed segment is not cache.");
+ return 0;
+ }
+
+ cache_pool_seg = first_seg(seg->pool_lv);
+
if (!(metadata_uuid = build_dm_uuid(mem, cache_pool_seg->metadata_lv, NULL)))
return_0;