From: Zhilong Liu <zlliu@suse.com>
To: Jes.Sorensen@gmail.com
Cc: linux-raid@vger.kernel.org, Zhilong Liu <zlliu@suse.com>
Subject: [PATCH 3/4] mdadm:triggers core dump when stat2devnm return NULL
Date: Wed, 8 Mar 2017 15:52:21 +0800 [thread overview]
Message-ID: <20170308075221.24965-1-zlliu@suse.com> (raw)
In-Reply-To: <20170308074831.24683-1-zlliu@suse.com>
ensure that the device should be a block device when uses
--wait parameter, such as the 'f' and 'd' type file would
be triggered core dumped.
./mdadm --wait /dev/md/, happened core dump.
Signed-off-by: Zhilong Liu <zlliu@suse.com>
diff --git a/Monitor.c b/Monitor.c
index 802a9d9..1900db3 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -1002,6 +1002,10 @@ int Wait(char *dev)
strerror(errno));
return 2;
}
+ if ((S_IFMT & stb.st_mode) != S_IFBLK) {
+ pr_err("%s is not a block device.\n", dev);
+ return 2;
+ }
strcpy(devnm, stat2devnm(&stb));
while(1) {
diff --git a/lib.c b/lib.c
index b640634..7116298 100644
--- a/lib.c
+++ b/lib.c
@@ -89,9 +89,6 @@ char *devid2kname(int devid)
char *stat2kname(struct stat *st)
{
- if ((S_IFMT & st->st_mode) != S_IFBLK)
- return NULL;
-
return devid2kname(st->st_rdev);
}
--
2.10.2
next prev parent reply other threads:[~2017-03-08 7:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-08 7:48 [PATCH 0/4] mdadm:checking level once mode has been set Zhilong Liu
2017-03-08 7:50 ` [PATCH 1/4] mdadm:bitmap cannot be set twice Zhilong Liu
2017-03-08 8:07 ` [PATCH 5/5] mdadm:checking level once mode has been set Zhilong Liu
2017-03-08 7:51 ` [PATCH 2/4] mdadm:external bitmap only supports ext filesystem Zhilong Liu
2017-03-12 14:48 ` Liu Zhilong
2017-03-13 8:16 ` zhilong
2017-03-08 7:52 ` Zhilong Liu [this message]
2017-03-12 23:00 ` [PATCH 3/4] mdadm:triggers core dump when stat2devnm return NULL NeilBrown
2017-03-13 5:34 ` zhilong
2017-03-13 7:01 ` [PATCH 3/4 v1] " Zhilong Liu
2017-03-12 22:54 ` [PATCH 0/4] mdadm:checking level once mode has been set NeilBrown
2017-03-13 3:22 ` zhilong
2017-03-13 3:48 ` NeilBrown
2017-03-13 5:16 ` zhilong
2017-03-17 19:30 ` jes.sorensen
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=20170308075221.24965-1-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).