]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix for possible NULL pointer dereference.
authorArtur Wojcik <artur.wojcik@intel.com>
Thu, 10 Dec 2009 19:03:37 +0000 (12:03 -0700)
committerDan Williams <dan.j.williams@intel.com>
Thu, 10 Dec 2009 19:03:37 +0000 (12:03 -0700)
Pointer 'this' returned from call to function 'malloc' at line 3795
may be NULL and will be dereferenced at line 3796.

Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
super-intel.c

index 2e119f831fc5d260ccc253d399058142b428304d..5e8378f996a4ff28c72f634a2ebecdf5154c4e91 100644 (file)
@@ -3804,6 +3804,11 @@ static struct mdinfo *container_content_imsm(struct supertype *st)
                }
 
                this = malloc(sizeof(*this));
+               if (!this) {
+                       fprintf(stderr, Name ": failed to allocate %lu bytes\n",
+                               sizeof(*this));
+                       break;
+               }
                memset(this, 0, sizeof(*this));
                this->next = rest;
 
@@ -3821,7 +3826,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st)
                        ord = get_imsm_ord_tbl_ent(dev, slot); 
                        for (d = super->disks; d ; d = d->next)
                                if (d->index == idx)
-                                        break;
+                                       break;
 
                        if (d == NULL)
                                skip = 1;