Blame SOURCES/0037-mdadm-Fix-optional-write-behind-parameter.patch

25786b
From 41edf6f45895193f4a523cb0a08d639c9ff9ccc9 Mon Sep 17 00:00:00 2001
25786b
From: Logan Gunthorpe <logang@deltatee.com>
25786b
Date: Wed, 22 Jun 2022 14:25:12 -0600
91179e
Subject: [PATCH 37/83] mdadm: Fix optional --write-behind parameter
25786b
25786b
The commit noted below changed the behaviour of --write-behind to
25786b
require an argument. This broke the 06wrmostly test with the error:
25786b
25786b
  mdadm: Invalid value for maximum outstanding write-behind writes: (null).
25786b
         Must be between 0 and 16383.
25786b
25786b
To fix this, check if optarg is NULL before parising it, as the origial
25786b
code did.
25786b
25786b
Fixes: 60815698c0ac ("Refactor parse_num and use it to parse optarg.")
25786b
Cc: Mateusz Grzonka <mateusz.grzonka@intel.com>
25786b
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
25786b
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
25786b
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
25786b
---
25786b
 mdadm.c | 5 +++--
25786b
 1 file changed, 3 insertions(+), 2 deletions(-)
25786b
25786b
diff --git a/mdadm.c b/mdadm.c
25786b
index d0c5e6de..56722ed9 100644
25786b
--- a/mdadm.c
25786b
+++ b/mdadm.c
25786b
@@ -1201,8 +1201,9 @@ int main(int argc, char *argv[])
25786b
 		case O(BUILD, WriteBehind):
25786b
 		case O(CREATE, WriteBehind):
25786b
 			s.write_behind = DEFAULT_MAX_WRITE_BEHIND;
25786b
-			if (parse_num(&s.write_behind, optarg) != 0 ||
25786b
-			s.write_behind < 0 || s.write_behind > 16383) {
25786b
+			if (optarg &&
25786b
+			    (parse_num(&s.write_behind, optarg) != 0 ||
25786b
+			     s.write_behind < 0 || s.write_behind > 16383)) {
25786b
 				pr_err("Invalid value for maximum outstanding write-behind writes: %s.\n\tMust be between 0 and 16383.\n",
25786b
 						optarg);
25786b
 				exit(2);
25786b
-- 
91179e
2.38.1
25786b