linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhilong Liu <zlliu@suse.com>
To: Jes.Sorensen@gmail.com
Cc: linux-raid@vger.kernel.org, Zhilong Liu <zlliu@suse.com>
Subject: [PATCH 4/4] mdadm/Monitor:check the block device when use waitclean parameter
Date: Sat,  1 Apr 2017 20:51:45 +0800	[thread overview]
Message-ID: <20170401125145.14440-5-zlliu@suse.com> (raw)
In-Reply-To: <20170401125145.14440-1-zlliu@suse.com>

WaitClean(): stat2devnm() returns NULL for non block devices.
Check the pointer is valid derefencing it. This would happen
when using --waitclean, such as the 'f' and 'd' file type,
causing a core dump.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
---
 Monitor.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Monitor.c b/Monitor.c
index 036a561..101b765 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -1076,6 +1076,8 @@ int WaitClean(char *dev, int sock, int verbose)
 			pr_err("Couldn't open %s: %s\n", dev, strerror(errno));
 		return 1;
 	}
+	if (check_blkdev_via_fstat(fd, dev))
+		return 2;
 
 	strcpy(devnm, fd2devnm(fd));
 	mdi = sysfs_read(fd, devnm, GET_VERSION|GET_LEVEL|GET_SAFEMODE);
-- 
2.10.2


  parent reply	other threads:[~2017-04-01 12:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-01 12:51 [PATCH 0/4] integrated stat and fstat into utility functions Zhilong Liu
2017-04-01 12:51 ` [PATCH 1/4] mdadm/util:integrate stat operations into one utility Zhilong Liu
2017-04-05 15:42   ` jes.sorensen
2017-04-14 10:14     ` Liu Zhilong
2017-04-14 15:20       ` Jes Sorensen
2017-04-17  7:08         ` Liu Zhilong
2017-04-17  7:18           ` Zhilong Liu
2017-04-20 16:42           ` Jes Sorensen
2017-04-01 12:51 ` [PATCH 2/4] mdadm/util:integrate fstat operations into one utility function Zhilong Liu
2017-04-05 15:43   ` jes.sorensen
2017-04-01 12:51 ` [PATCH 3/4] mdadm/Create:declaring an existing struct within same function Zhilong Liu
2017-04-05 15:47   ` jes.sorensen
2017-04-01 12:51 ` Zhilong Liu [this message]
2017-04-14 12:31 ` [PATCH 0/4] integrated stat and fstat into utility functions Paul Menzel
2017-04-17  2:23   ` Zhilong Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170401125145.14440-5-zlliu@suse.com \
    --to=zlliu@suse.com \
    --cc=Jes.Sorensen@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).