blob: fafe88b49c7e14f288fc13b585afd5543de376b8 [file] [log] [blame]
Andrew Geissler8f840682023-07-21 09:09:43 -05001From 14f110f0286d38e29ef5e51d7f72e049c2f18323 Mon Sep 17 00:00:00 2001
2From: Logan Gunthorpe <logang@deltatee.com>
3Date: Wed, 22 Jun 2022 14:25:08 -0600
4Subject: [PATCH 2/4] DDF: Fix NULL pointer dereference in
5 validate_geometry_ddf()
6
7A relatively recent patch added a call to validate_geometry() in
8Manage_add() that has level=LEVEL_CONTAINER and chunk=NULL.
9
10This causes some ddf tests to segfault which aborts the test suite.
11
12To fix this, avoid dereferencing chunk when the level is
13LEVEL_CONTAINER or LEVEL_NONE.
14
15Fixes: 1f5d54a06df0 ("Manage: Call validate_geometry when adding drive to external container")
16Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
17Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
18Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
19
20Upstream-Status: Backport
21
22Reference to upstream patch:
23https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/?id=2b93288a5650
24
25Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
26---
27 super-ddf.c | 6 +++---
28 1 file changed, 3 insertions(+), 3 deletions(-)
29
30diff --git a/super-ddf.c b/super-ddf.c
31index 65cf727..3ef1293 100644
32--- a/super-ddf.c
33+++ b/super-ddf.c
34@@ -3369,9 +3369,6 @@ static int validate_geometry_ddf(struct supertype *st,
35 * If given BVDs, we make an SVD, changing all the GUIDs in the process.
36 */
37
38- if (*chunk == UnSet)
39- *chunk = DEFAULT_CHUNK;
40-
41 if (level == LEVEL_NONE)
42 level = LEVEL_CONTAINER;
43 if (level == LEVEL_CONTAINER) {
44@@ -3381,6 +3378,9 @@ static int validate_geometry_ddf(struct supertype *st,
45 freesize, verbose);
46 }
47
48+ if (*chunk == UnSet)
49+ *chunk = DEFAULT_CHUNK;
50+
51 if (!dev) {
52 mdu_array_info_t array = {
53 .level = level,
54--
552.39.1
56