From efcdf9f5c8dfb1fa2b052e58e4ccb85541aee2cd Mon Sep 17 00:00:00 2001 From: Joe Carnuccio Date: Thu, 25 Sep 2014 05:16:41 -0400 Subject: [PATCH] qla2xxx: Fix potential return count bug in qla2xxx_get_vpd_field(). Call scnprintf() instead of snprintf() since the latter may return an incorrect count in cases where the write is truncated to fit. scnprintf() returns the count of what was actually written; snprintf() returns the count of what would have been written. Signed-off-by: Joe Carnuccio Signed-off-by: Saurav Kashyap Signed-off-by: Christoph Hellwig --- drivers/scsi/qla2xxx/qla_sup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index 04b370182742..4788ecd0c42a 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c @@ -3163,7 +3163,7 @@ qla2xxx_get_vpd_field(scsi_qla_host_t *vha, char *key, char *str, size_t size) } if (pos < end - len && *pos != 0x78) - return snprintf(str, size, "%.*s", len, pos + 3); + return scnprintf(str, size, "%.*s", len, pos + 3); return 0; } -- 2.39.5