linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] monitor: fix nullptr dereference when get_md_name() returns NULL
@ 2014-10-10 13:23 Sergey Vidishev
  2015-05-18 23:33 ` [PATCH v2] mdadm: " Sergey Vidishev
  0 siblings, 1 reply; 6+ messages in thread
From: Sergey Vidishev @ 2014-10-10 13:23 UTC (permalink / raw)
  To: NeilBrown; +Cc: linux-raid, sergeyv

From f35857936a8df2155b9aee3759c91fc19b77842c Mon Sep 17 00:00:00 2001
From: Sergey Vidishev <sergeyv@yandex-team.ru>
Date: Wed, 8 Oct 2014 21:51:03 +0400
Subject: [PATCH] monitor: fix nullptr dereference when get_md_name() returns NULL

Signed-off-by: Sergey Vidishev <sergeyv@yandex-team.ru>
---

This patch against fresh git://neil.brown.name/mdadm.
I'm not subscribed to the list, please CC me in replies.

 Monitor.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Monitor.c b/Monitor.c
index 5cb24fa..1919f99 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -668,6 +668,7 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
 {
 	struct mdstat_ent *mse;
 	int new_found = 0;
+	char *name;
 
 	for (mse=mdstat; mse; mse=mse->next)
 		if (mse->devnm[0] &&
@@ -678,7 +679,12 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
 			struct state *st = xcalloc(1, sizeof *st);
 			mdu_array_info_t array;
 			int fd;
-			st->devname = xstrdup(get_md_name(mse->devnm));
+
+			name = get_md_name(mse->devnm);
+			if (!name)
+				return 0;
+
+			st->devname = xstrdup(name);
 			if ((fd = open(st->devname, O_RDONLY)) < 0 ||
 			    ioctl(fd, GET_ARRAY_INFO, &array)< 0) {
 				/* no such array */
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-20  3:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-10 13:23 [PATCH] monitor: fix nullptr dereference when get_md_name() returns NULL Sergey Vidishev
2015-05-18 23:33 ` [PATCH v2] mdadm: " Sergey Vidishev
2015-05-19  1:42   ` David F.
2015-05-19 18:39     ` Sergey Vidishev
2015-05-19 19:02       ` [PATCH v3] " Sergey Vidishev
2015-05-20  3:16         ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).