[PATCH] imsm: fix reading scsi serial

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
Tested-by: NeilBrown <neilb@xxxxxxxx>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@xxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux