summaryrefslogtreecommitdiffstats
path: root/sg_io.c
diff options
context:
space:
mode:
authorArtur Paszkiewicz <artur.paszkiewicz@intel.com>2017-11-02 16:10:57 +0100
committerJes Sorensen <jsorensen@fb.com>2017-11-02 16:33:09 +0100
commit01a052b9c1c6bdc7307a3f8e8d12db262d9b258c (patch)
tree7d5af1f92967ee5d271fc454b98d95ce4e6d3709 /sg_io.c
parentIncremental: Use ->validate_geometry instead of ->avail_size (diff)
downloadmdadm-01a052b9c1c6bdc7307a3f8e8d12db262d9b258c.tar.xz
mdadm-01a052b9c1c6bdc7307a3f8e8d12db262d9b258c.zip
imsm: fix reading scsi serial
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> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'sg_io.c')
-rw-r--r--sg_io.c3
1 files changed, 3 insertions, 0 deletions
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)