forked from pool/mdadm
40 lines
1.1 KiB
Diff
40 lines
1.1 KiB
Diff
|
From 01a052b9c1c6bdc7307a3f8e8d12db262d9b258c Mon Sep 17 00:00:00 2001
|
||
|
From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
|
||
|
Date: Thu, 2 Nov 2017 16:10:57 +0100
|
||
|
Subject: [PATCH] imsm: fix reading scsi serial
|
||
|
Git-commit: 01a052b9c1c6bdc7307a3f8e8d12db262d9b258c
|
||
|
Patch-mainline: mdadm-4.0+
|
||
|
References: bsc#1069165, bsc#1069167, bsc#1068030
|
||
|
|
||
|
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>
|
||
|
Signed-off-by: Coly Li <colyli@suse.de>
|
||
|
|
||
|
---
|
||
|
sg_io.c | 3 +++
|
||
|
1 file changed, 3 insertions(+)
|
||
|
|
||
|
diff --git a/sg_io.c b/sg_io.c
|
||
|
index 42c91e1..7889a95 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.13.6
|
||
|
|