]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-intel.c
Fix for possible NULL pointer dereference.
[thirdparty/mdadm.git] / super-intel.c
index 9a99d609b4a83079c1064222be483eb4791e2fe8..5e8378f996a4ff28c72f634a2ebecdf5154c4e91 100644 (file)
@@ -3704,8 +3704,11 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout,
                case 1:
                case 10:
                case 5:
-                       break;
+                       return 0;
                default:
+                       if (verbose)
+                               fprintf(stderr, Name
+                                       ": IMSM only supports levels 0,1,5,10\n");
                        return 1;
                }
 
@@ -3801,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;
 
@@ -3818,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;