From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
To: jes.sorensen@gmail.com
Cc: linux-raid@vger.kernel.org, neilb@suse.com,
Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Subject: [PATCH] imsm: fix reading scsi serial
Date: Thu, 2 Nov 2017 16:10:57 +0100 [thread overview]
Message-ID: <20171102151057.3398-1-artur.paszkiewicz@intel.com> (raw)
Improve error detection after SG_IO ioctl. Checking only the return
value and response length is insufficient and leads to anomalies if a
drive does not have a serial number.
Reported-by: NeilBrown <neilb@suse.com>
Tested-by: NeilBrown <neilb@suse.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
---
Mailing list discussion: https://marc.info/?l=linux-raid&m=150950864700415&w=2
sg_io.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sg_io.c b/sg_io.c
index 42c91e1e..7889a95e 100644
--- a/sg_io.c
+++ b/sg_io.c
@@ -46,6 +46,9 @@ int scsi_get_serial(int fd, void *buf, size_t buf_len)
if (rv)
return rv;
+ if ((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK)
+ return -1;
+
rsp_len = rsp_buf[3];
if (!rsp_len || buf_len < rsp_len)
--
2.14.2
next reply other threads:[~2017-11-02 15:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-02 15:10 Artur Paszkiewicz [this message]
2017-11-02 15:33 ` [PATCH] imsm: fix reading scsi serial 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=20171102151057.3398-1-artur.paszkiewicz@intel.com \
--to=artur.paszkiewicz@intel.com \
--cc=jes.sorensen@gmail.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.com \
/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).