]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: Fix optional --write-behind parameter
authorLogan Gunthorpe <logang@deltatee.com>
Wed, 22 Jun 2022 20:25:12 +0000 (14:25 -0600)
committerJes Sorensen <jes@trained-monkey.org>
Sun, 7 Aug 2022 20:27:59 +0000 (16:27 -0400)
The commit noted below changed the behaviour of --write-behind to
require an argument. This broke the 06wrmostly test with the error:

  mdadm: Invalid value for maximum outstanding write-behind writes: (null).
         Must be between 0 and 16383.

To fix this, check if optarg is NULL before parising it, as the origial
code did.

Fixes: 60815698c0ac ("Refactor parse_num and use it to parse optarg.")
Cc: Mateusz Grzonka <mateusz.grzonka@intel.com>
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>
mdadm.c

diff --git a/mdadm.c b/mdadm.c
index d0c5e6def901611974d463cde8d5205838fe65fd..56722ed997a2a22c1705fa5f23884afecd147d20 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1201,8 +1201,9 @@ int main(int argc, char *argv[])
                case O(BUILD, WriteBehind):
                case O(CREATE, WriteBehind):
                        s.write_behind = DEFAULT_MAX_WRITE_BEHIND;
-                       if (parse_num(&s.write_behind, optarg) != 0 ||
-                       s.write_behind < 0 || s.write_behind > 16383) {
+                       if (optarg &&
+                           (parse_num(&s.write_behind, optarg) != 0 ||
+                            s.write_behind < 0 || s.write_behind > 16383)) {
                                pr_err("Invalid value for maximum outstanding write-behind writes: %s.\n\tMust be between 0 and 16383.\n",
                                                optarg);
                                exit(2);