Skip to content

Commit 0e48e7a

Browse files
Dan CarpenterNicholas Bellinger
authored andcommitted
target: don't truncate the fail intr address
The temporary buffer was only 32 characters but ->last_intr_fail_ip_addr is a 48 character buffer. We don't need to use a temporary buffer at all, we can just print directly to "page". Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 07ea81b commit 0e48e7a

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

‎drivers/target/iscsi/iscsi_target_stat.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,16 +429,19 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr(
429429
struct iscsi_tiqn *tiqn = container_of(igrps,
430430
struct iscsi_tiqn, tiqn_stat_grps);
431431
struct iscsi_login_stats *lstat = &tiqn->login_stats;
432-
unsigned char buf[32];
432+
int ret;
433433

434434
spin_lock(&lstat->lock);
435-
if (lstat->last_intr_fail_ip_family == AF_INET6)
436-
snprintf(buf, 32, "[%s]", lstat->last_intr_fail_ip_addr);
437-
else
438-
snprintf(buf, 32, "%s", lstat->last_intr_fail_ip_addr);
435+
if (lstat->last_intr_fail_ip_family == AF_INET6) {
436+
ret = snprintf(page, PAGE_SIZE, "[%s]\n",
437+
lstat->last_intr_fail_ip_addr);
438+
} else {
439+
ret = snprintf(page, PAGE_SIZE, "%s\n",
440+
lstat->last_intr_fail_ip_addr);
441+
}
439442
spin_unlock(&lstat->lock);
440443

441-
return snprintf(page, PAGE_SIZE, "%s\n", buf);
444+
return ret;
442445
}
443446
ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr);
444447

0 commit comments

Comments
 (0)