aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/iscsi/iscsi_target_stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/target/iscsi/iscsi_target_stat.c')
-rw-r--r--drivers/target/iscsi/iscsi_target_stat.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/target/iscsi/iscsi_target_stat.c b/drivers/target/iscsi/iscsi_target_stat.c
index 421d6947dc64..464b4206a51e 100644
--- a/drivers/target/iscsi/iscsi_target_stat.c
+++ b/drivers/target/iscsi/iscsi_target_stat.c
@@ -410,14 +410,16 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr_type(
410 struct iscsi_tiqn *tiqn = container_of(igrps, 410 struct iscsi_tiqn *tiqn = container_of(igrps,
411 struct iscsi_tiqn, tiqn_stat_grps); 411 struct iscsi_tiqn, tiqn_stat_grps);
412 struct iscsi_login_stats *lstat = &tiqn->login_stats; 412 struct iscsi_login_stats *lstat = &tiqn->login_stats;
413 unsigned char buf[8]; 413 int ret;
414 414
415 spin_lock(&lstat->lock); 415 spin_lock(&lstat->lock);
416 snprintf(buf, 8, "%s", (lstat->last_intr_fail_ip_addr != NULL) ? 416 if (lstat->last_intr_fail_ip_family == AF_INET6)
417 "ipv6" : "ipv4"); 417 ret = snprintf(page, PAGE_SIZE, "ipv6\n");
418 else
419 ret = snprintf(page, PAGE_SIZE, "ipv4\n");
418 spin_unlock(&lstat->lock); 420 spin_unlock(&lstat->lock);
419 421
420 return snprintf(page, PAGE_SIZE, "%s\n", buf); 422 return ret;
421} 423}
422ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr_type); 424ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr_type);
423 425
@@ -427,16 +429,19 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr(
427 struct iscsi_tiqn *tiqn = container_of(igrps, 429 struct iscsi_tiqn *tiqn = container_of(igrps,
428 struct iscsi_tiqn, tiqn_stat_grps); 430 struct iscsi_tiqn, tiqn_stat_grps);
429 struct iscsi_login_stats *lstat = &tiqn->login_stats; 431 struct iscsi_login_stats *lstat = &tiqn->login_stats;
430 unsigned char buf[32]; 432 int ret;
431 433
432 spin_lock(&lstat->lock); 434 spin_lock(&lstat->lock);
433 if (lstat->last_intr_fail_ip_family == AF_INET6) 435 if (lstat->last_intr_fail_ip_family == AF_INET6) {
434 snprintf(buf, 32, "[%s]", lstat->last_intr_fail_ip_addr); 436 ret = snprintf(page, PAGE_SIZE, "[%s]\n",
435 else 437 lstat->last_intr_fail_ip_addr);
436 snprintf(buf, 32, "%s", lstat->last_intr_fail_ip_addr); 438 } else {
439 ret = snprintf(page, PAGE_SIZE, "%s\n",
440 lstat->last_intr_fail_ip_addr);
441 }
437 spin_unlock(&lstat->lock); 442 spin_unlock(&lstat->lock);
438 443
439 return snprintf(page, PAGE_SIZE, "%s\n", buf); 444 return ret;
440} 445}
441ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr); 446ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr);
442 447