Skip to contentSkip to conversation

x86/intel_rdt: fix rdt_mount error handling

PATCH In review Arnd Bergmann 3 participants 3 messages Nov 8, 2016 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/intel_rdt: fix rdt_mount error handling

The newly introduced rdt_mount function returns an unintialized pointer if rdtgroup_create_info_dir() fails:

arch/x86/kernel/cpu/intel_rdt_rdtgroup.c: In function ‘rdt_mount’:
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c:710:9: error: ‘dentry’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

Clearly the intention was to propagate the error code here as we do in the other failure cases.

Fixes 5ff193fbde20 ("x86/intel_rdt: Add basic resctrl filesystem support")
---
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +3 -1
index a90ad22b9823..e66c7a58505e 100644
@@ -691,8 +691,10 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type,
 	closid_init();
 
 	ret = rdtgroup_create_info_dir(rdtgroup_default.kn);
-	if (ret)
+	if (ret) {
+		dentry = ERR_PTR(ret);
 		goto out_cdp;
+	}
 
 	dentry = kernfs_mount(fs_type, flags, rdt_root,
 			      RDTGROUP_SUPER_MAGIC, NULL);
Signature · 1 line
2.9.0
#2 lore raw
In reply to Arnd Bergmann
Quoted 34 lines

From: Arnd Bergmann [mailto:[email protected]]
The newly introduced rdt_mount function returns an unintialized pointer if rdtgroup_create_info_dir() fails:

arch/x86/kernel/cpu/intel_rdt_rdtgroup.c: In function ‘rdt_mount’:
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c:710:9: error: ‘dentry’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

Clearly the intention was to propagate the error code here as we do in the other failure cases.

Fixes 5ff193fbde20 ("x86/intel_rdt: Add basic resctrl filesystem support")
---
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +3 -1
index a90ad22b9823..e66c7a58505e 100644
@@ -691,8 +691,10 @@ static struct dentry *rdt_mount(struct
 file_system_type *fs_type,
 	closid_init();
 
 	ret = rdtgroup_create_info_dir(rdtgroup_default.kn);
-	if (ret)
+	if (ret) {
+		dentry = ERR_PTR(ret);
 		goto out_cdp;
+	}
 
 	dentry = kernfs_mount(fs_type, flags, rdt_root,
Quoted 1 line

RDTGROUP_SUPER_MAGIC, NULL);

The warning has been fixed and pushed in tip tree already:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=x86/cache&id=7bff0af51012500718971f9cc3485f67252353eb

Thanks.

-Fenghua