Skip to content

Commit df8cea2

Browse files
Chen ZhouVasily Gorbik
authored andcommitted
s390/crypto: use scnprintf() instead of snprintf()
snprintf() returns the number of bytes that would be written, which may be greater than the the actual length to be written. show() methods should return the number of bytes printed into the buffer. This is the return value of scnprintf(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Chen Zhou <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 79d6c50 commit df8cea2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

arch/s390/crypto/prng.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ static ssize_t prng_chunksize_show(struct device *dev,
693693
struct device_attribute *attr,
694694
char *buf)
695695
{
696-
return snprintf(buf, PAGE_SIZE, "%u\n", prng_chunk_size);
696+
return scnprintf(buf, PAGE_SIZE, "%u\n", prng_chunk_size);
697697
}
698698
static DEVICE_ATTR(chunksize, 0444, prng_chunksize_show, NULL);
699699

@@ -712,7 +712,7 @@ static ssize_t prng_counter_show(struct device *dev,
712712
counter = prng_data->prngws.byte_counter;
713713
mutex_unlock(&prng_data->mutex);
714714

715-
return snprintf(buf, PAGE_SIZE, "%llu\n", counter);
715+
return scnprintf(buf, PAGE_SIZE, "%llu\n", counter);
716716
}
717717
static DEVICE_ATTR(byte_counter, 0444, prng_counter_show, NULL);
718718

@@ -721,7 +721,7 @@ static ssize_t prng_errorflag_show(struct device *dev,
721721
struct device_attribute *attr,
722722
char *buf)
723723
{
724-
return snprintf(buf, PAGE_SIZE, "%d\n", prng_errorflag);
724+
return scnprintf(buf, PAGE_SIZE, "%d\n", prng_errorflag);
725725
}
726726
static DEVICE_ATTR(errorflag, 0444, prng_errorflag_show, NULL);
727727

@@ -731,9 +731,9 @@ static ssize_t prng_mode_show(struct device *dev,
731731
char *buf)
732732
{
733733
if (prng_mode == PRNG_MODE_TDES)
734-
return snprintf(buf, PAGE_SIZE, "TDES\n");
734+
return scnprintf(buf, PAGE_SIZE, "TDES\n");
735735
else
736-
return snprintf(buf, PAGE_SIZE, "SHA512\n");
736+
return scnprintf(buf, PAGE_SIZE, "SHA512\n");
737737
}
738738
static DEVICE_ATTR(mode, 0444, prng_mode_show, NULL);
739739

@@ -756,7 +756,7 @@ static ssize_t prng_reseed_limit_show(struct device *dev,
756756
struct device_attribute *attr,
757757
char *buf)
758758
{
759-
return snprintf(buf, PAGE_SIZE, "%u\n", prng_reseed_limit);
759+
return scnprintf(buf, PAGE_SIZE, "%u\n", prng_reseed_limit);
760760
}
761761
static ssize_t prng_reseed_limit_store(struct device *dev,
762762
struct device_attribute *attr,
@@ -787,7 +787,7 @@ static ssize_t prng_strength_show(struct device *dev,
787787
struct device_attribute *attr,
788788
char *buf)
789789
{
790-
return snprintf(buf, PAGE_SIZE, "256\n");
790+
return scnprintf(buf, PAGE_SIZE, "256\n");
791791
}
792792
static DEVICE_ATTR(strength, 0444, prng_strength_show, NULL);
793793

0 commit comments

Comments
 (0)