Skip to content

Commit 9944801

Browse files
Chen ZhouVasily Gorbik
authored andcommitted
s390/protvirt: 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. uv_query_facilities() should return the number of bytes printed into the buffer. This is the return value of scnprintf(). The other functions are the same. 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 92fd356 commit 9944801

File tree

1 file changed

+4
-4
lines changed
  • arch/s390/kernel

1 file changed

+4
-4
lines changed

arch/s390/kernel/uv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ EXPORT_SYMBOL_GPL(arch_make_page_accessible);
331331
static ssize_t uv_query_facilities(struct kobject *kobj,
332332
struct kobj_attribute *attr, char *page)
333333
{
334-
return snprintf(page, PAGE_SIZE, "%lx\n%lx\n%lx\n%lx\n",
334+
return scnprintf(page, PAGE_SIZE, "%lx\n%lx\n%lx\n%lx\n",
335335
uv_info.inst_calls_list[0],
336336
uv_info.inst_calls_list[1],
337337
uv_info.inst_calls_list[2],
@@ -344,7 +344,7 @@ static struct kobj_attribute uv_query_facilities_attr =
344344
static ssize_t uv_query_max_guest_cpus(struct kobject *kobj,
345345
struct kobj_attribute *attr, char *page)
346346
{
347-
return snprintf(page, PAGE_SIZE, "%d\n",
347+
return scnprintf(page, PAGE_SIZE, "%d\n",
348348
uv_info.max_guest_cpus);
349349
}
350350

@@ -354,7 +354,7 @@ static struct kobj_attribute uv_query_max_guest_cpus_attr =
354354
static ssize_t uv_query_max_guest_vms(struct kobject *kobj,
355355
struct kobj_attribute *attr, char *page)
356356
{
357-
return snprintf(page, PAGE_SIZE, "%d\n",
357+
return scnprintf(page, PAGE_SIZE, "%d\n",
358358
uv_info.max_num_sec_conf);
359359
}
360360

@@ -364,7 +364,7 @@ static struct kobj_attribute uv_query_max_guest_vms_attr =
364364
static ssize_t uv_query_max_guest_addr(struct kobject *kobj,
365365
struct kobj_attribute *attr, char *page)
366366
{
367-
return snprintf(page, PAGE_SIZE, "%lx\n",
367+
return scnprintf(page, PAGE_SIZE, "%lx\n",
368368
uv_info.max_sec_stor_addr);
369369
}
370370

0 commit comments

Comments
 (0)