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

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