]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Manage: Manage_add(): Avoid NULL initialization of dev_st
authorJes Sorensen <Jes.Sorensen@redhat.com>
Wed, 9 Mar 2016 19:51:03 +0000 (14:51 -0500)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 22 Mar 2016 18:06:07 +0000 (14:06 -0400)
dev_st is only ever assigned if array->not_persistent == 0, so move
the second use of it into the same scope where the assignment is
made.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Manage.c

index 530826038a99652d10999f8a35daca573481d2a3..f6143967f3c401a53bfe06908c9d82f9c9491218 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -738,7 +738,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
               int raid_slot)
 {
        unsigned long long ldsize;
-       struct supertype *dev_st = NULL;
+       struct supertype *dev_st;
        int j;
        mdu_disk_info_t disc;
 
@@ -843,20 +843,19 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
                 * simply re-add it.
                 */
 
-               if (array->not_persistent==0) {
+               if (array->not_persistent == 0) {
                        dev_st = dup_super(tst);
                        dev_st->ss->load_super(dev_st, tfd, NULL);
-               }
-               if (dev_st && dev_st->sb && dv->disposition != 'S') {
-                       int rv = attempt_re_add(fd, tfd, dv,
-                                               dev_st, tst,
-                                               rdev,
-                                               update, devname,
-                                               verbose,
-                                               array);
-                       dev_st->ss->free_super(dev_st);
-                       if (rv)
-                               return rv;
+                       if (dev_st->sb && dv->disposition != 'S') {
+                               int rv;
+
+                               rv = attempt_re_add(fd, tfd, dv, dev_st, tst,
+                                                   rdev, update, devname,
+                                                   verbose, array);
+                               dev_st->ss->free_super(dev_st);
+                               if (rv)
+                                       return rv;
+                       }
                }
                if (dv->disposition == 'M') {
                        if (verbose > 0)