Re: [PATCH] x86/resctrl: Fix return code in mkdir_rdt_prepare()

From: Reinette Chatre
Date: Fri Sep 24 2021 - 14:53:44 EST

Hi Shaopeng Tan,

On 9/24/2021 1:17 AM, Shaopeng Tan wrote:
When kzalloc fails, we should return ENOMEM instead of ENOSPC.

Signed-off-by: Shaopeng Tan <tan.shaopeng@xxxxxxxxxxxxxx>

I just noticed this when I read the code.


arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index b57b3db9a6a7..a92d047476f6 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -2854,7 +2854,7 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
/* allocate the rdtgroup. */
rdtgrp = kzalloc(sizeof(*rdtgrp), GFP_KERNEL);
if (!rdtgrp) {
- ret = -ENOSPC;
+ ret = -ENOMEM;
rdt_last_cmd_puts("Kernel out of memory\n");
goto out_unlock;

I do not know the original motivation for using ENOSPC but from what I can tell this error is propagated all the way to user space. This change thus has the consequence that any interface built on top of resctrl could be impacted.

Is there a specific issue that you are aiming to fix here?