dm cache: detect cache_create failure
authorHeinz Mauelshagen <heinzm@redhat.com>
Wed, 20 Mar 2013 17:21:26 +0000 (17:21 +0000)
committerAlasdair G Kergon <agk@redhat.com>
Wed, 20 Mar 2013 17:21:26 +0000 (17:21 +0000)
Return error if cache_create() fails.

A missing return check made cache_ctr continue even after an error in
cache_create() resulting in the cache object being destroyed.  So a
simple failure like an odd number of cache policy config value arguments
would result in an oops.

Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-cache-target.c

index 5ad227f0cea3f8af09c9131e95f4e7f3a1497d31..76cc910557f049b59a0b81fc384167cf82af6669 100644 (file)
@@ -2009,6 +2009,8 @@ static int cache_ctr(struct dm_target *ti, unsigned argc, char **argv)
                goto out;
 
        r = cache_create(ca, &cache);
+       if (r)
+               goto out;
 
        r = copy_ctr_args(cache, argc - 3, (const char **)argv + 3);
        if (r) {