Skip to contentSkip to conversation

orangefs-debugfs: fix a missing-check bug in debug_string_to_mask()

PATCH In review Gen Zhang 2 participants 2 messages May 30, 2019 – Jun 5, 2019 Orangefs filesystem

lore
Share & tools
lore

Gen Zhang

author
#0 lore raw

PATCH 1/1 orangefs-debugfs: fix a missing-check bug in debug_string_to_mask()

In debug_string_to_mask(), 'strsep_fodder' is allocated by kstrdup(). It returns NULL when fails. So 'strsep_fodder' should be checked.

Signed-off-by Gen Zhang <blackgod016574.gmail>

---

fs/orangefs/orangefs-debugfs.c +2 -0
index 87b1a6f..a9a9aac 100644
@@ -888,6 +888,8 @@ static void debug_string_to_mask(char *debug_string, void *mask, int type)
 	char *unchecked_keyword;
 	int i;
 	char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL);
+	if (!strsep_fodder)
+		return;
 	char *original_pointer;
 	int element_count = 0;
 	struct client_debug_mask *c_mask = NULL;
#1 lore raw
Quoted 10 lines · Gen Zhang

In debug_string_to_mask(), 'strsep_fodder' is allocated by kstrdup(). It returns NULL when fails. So 'strsep_fodder' should be checked.

Signed-off-by Gen Zhang <blackgod016574.gmail>

---

fs/orangefs/orangefs-debugfs.c +0 -0
index 87b1a6f..a9a9aac 100644

fs/orangefs/orangefs-debugfs.c static void debug_string_to_mask(char *debug_string, void *mask, int type) · line 893

Quoted 6 lines
fs/orangefs/orangefs-debugfs.c +2 -0
@@ -888,6 +888,8 @@ static void debug_string_to_mask(char *debug_string, void *mask, int type)
 	char *unchecked_keyword;
 	int i;
 	char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL);
+	if (!strsep_fodder)
+		return;
 	char *original_pointer;

You should get a compiler error/warning about mixing declarations with code.

thanks,

Signature · 2 lines
js
suse labs