]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
DDF: Fix NULL pointer dereference in validate_geometry_ddf()
authorLogan Gunthorpe <logang@deltatee.com>
Wed, 22 Jun 2022 20:25:08 +0000 (14:25 -0600)
committerJes Sorensen <jes@trained-monkey.org>
Sun, 7 Aug 2022 20:27:59 +0000 (16:27 -0400)
A relatively recent patch added a call to validate_geometry() in
Manage_add() that has level=LEVEL_CONTAINER and chunk=NULL.

This causes some ddf tests to segfault which aborts the test suite.

To fix this, avoid dereferencing chunk when the level is
LEVEL_CONTAINER or LEVEL_NONE.

Fixes: 1f5d54a06df0 ("Manage: Call validate_geometry when adding drive to external container")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
super-ddf.c

index 9d867f6910f39347d1b7dda97c6a8c4dba276799..949e7d15547466701ffc39d507002fb2fb4f87b1 100644 (file)
@@ -3369,9 +3369,6 @@ static int validate_geometry_ddf(struct supertype *st,
         * If given BVDs, we make an SVD, changing all the GUIDs in the process.
         */
 
-       if (*chunk == UnSet)
-               *chunk = DEFAULT_CHUNK;
-
        if (level == LEVEL_NONE)
                level = LEVEL_CONTAINER;
        if (level == LEVEL_CONTAINER) {
@@ -3381,6 +3378,9 @@ static int validate_geometry_ddf(struct supertype *st,
                                                       freesize, verbose);
        }
 
+       if (*chunk == UnSet)
+               *chunk = DEFAULT_CHUNK;
+
        if (!dev) {
                mdu_array_info_t array = {
                        .level = level,