[PATCH 02/11] fs/resctrl: Avoid "may be used uninitialized" warning

Reinette Chatre
2026-03-02T18:46:29Z

Building resctrl with extra checks ("W=12") produces the following warning:
.../include/linux/ucopysize.h:22:17: warning: ‘buf’ may be used uninitialized [-Wmaybe-uninitialized]
22 | __check_object_size(ptr, n, to_user);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../include/linux/ucopysize.h: In function ‘pseudo_lock_measure_trigger’:
.../include/linux/ucopysize.h:10:13: note: by argument 1 of type ‘const void *’ to ‘__check_object_size’ declared here
10 | extern void __check_object_size(const void *ptr, unsigned long n,
| ^~~~~~~~~~~~~~~~~~~
.../fs/resctrl/pseudo_lock.c:754:14: note: ‘buf’ declared here
754 | char buf[32];
| ^~~

__check_object_size() ensures the provided buffer is within a valid location
but does not read from the uninitialized buffer. Even so, initialize the
buffer to silence the warning to help resctrl have a cleaner build.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
fs/resctrl/pseudo_lock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c
index e81d71abfe54..a857e51580e2 100644
--- a/fs/resctrl/pseudo_lock.c
+++ b/fs/resctrl/pseudo_lock.c
@@ -750,8 +750,8 @@ static ssize_t pseudo_lock_measure_trigger(struct file *file,
size_t count, loff_t *ppos)
{
struct rdtgroup *rdtgrp = file->private_data;
+ char buf[32] = {};
size_t buf_size;
- char buf[32];
int ret;
int sel;

--
2.50.1