]> git.hungrycats.org Git - linux/commitdiff
[PATCH] dm: stripe constructor validity check
authorJoe Thornber <joe@fib011235813.fsnet.co.uk>
Mon, 16 Dec 2002 01:16:21 +0000 (17:16 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Mon, 16 Dec 2002 01:16:21 +0000 (17:16 -0800)
There's a bug in the dm-stripe.c constructor failing top check if enough
destinations are handed in. [Heinz Mauelshagen]

drivers/md/dm-stripe.c

index 39ccd90b9c15921d4c9a4222a288304899135ff3..add4972726f0046378e7c168fd433e353ca009e1 100644 (file)
@@ -131,6 +131,15 @@ static int stripe_ctr(struct dm_target *ti, int argc, char **argv)
                return -EINVAL;
        }
 
+       /*
+        * Do we have enough arguments for that many stripes ?
+        */
+       if (argc != (2 + 2 * stripes)) {
+               ti->error = "dm-stripe: Not enough destinations "
+                       "specified";
+               return -EINVAL;
+       }
+
        sc = alloc_context(stripes);
        if (!sc) {
                ti->error = "dm-stripe: Memory allocation for striped context "
@@ -151,13 +160,6 @@ static int stripe_ctr(struct dm_target *ti, int argc, char **argv)
         * Get the stripe destinations.
         */
        for (i = 0; i < stripes; i++) {
-               if (argc < 2) {
-                       ti->error = "dm-stripe: Not enough destinations "
-                               "specified";
-                       kfree(sc);
-                       return -EINVAL;
-               }
-
                argv += 2;
 
                r = get_stripe(ti, sc, i, argv);