[PATCH v3 2/4] target: don't assume t10_wwn.vendor is null terminated

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

 



Signed-off-by: David Disseldorp <ddiss@xxxxxxx>
---
 drivers/target/target_core_stat.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c
index f0db91ebd735..89f35167f036 100644
--- a/drivers/target/target_core_stat.c
+++ b/drivers/target/target_core_stat.c
@@ -804,10 +804,17 @@ static ssize_t target_stat_transport_dev_name_show(struct config_item *item,
 	if (dev) {
 		wwn = &dev->t10_wwn;
 		/* scsiTransportDevName */
-		ret = snprintf(page, PAGE_SIZE, "%s+%s\n",
+		if (strlen(wwn->unit_serial)) {
+			ret = snprintf(page, PAGE_SIZE, "%s+%s\n",
+				tpg->se_tpg_tfo->tpg_get_wwn(tpg),
+				wwn->unit_serial);
+		} else {
+			ret = snprintf(page, PAGE_SIZE, "%s+%."
+				__stringify(INQUIRY_VENDOR_IDENTIFIER_LEN)
+				"s\n",
 				tpg->se_tpg_tfo->tpg_get_wwn(tpg),
-				(strlen(wwn->unit_serial)) ? wwn->unit_serial :
 				wwn->vendor);
+		}
 	}
 	rcu_read_unlock();
 	return ret;
-- 
2.13.7




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux