Skip to content

Commit 2605cf8

Browse files
Tao Cuigregkh
authored andcommitted
LoongArch: Check the return value when creating kobj
commit 51adb03 upstream. Add a check for the return value of kobject_create_and_add(), to ensure that the kobj allocation succeeds for later use. Cc: stable@vger.kernel.org Signed-off-by: Tao Cui <cuitao@kylinos.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e481c2f commit 2605cf8

File tree

1 file changed

+2
-0
lines changed
  • arch/loongarch/kernel

1 file changed

+2
-0
lines changed

arch/loongarch/kernel/env.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ static int __init boardinfo_init(void)
7070
struct kobject *loongson_kobj;
7171

7272
loongson_kobj = kobject_create_and_add("loongson", firmware_kobj);
73+
if (!loongson_kobj)
74+
return -ENOMEM;
7375

7476
return sysfs_create_file(loongson_kobj, &boardinfo_attr.attr);
7577
}

0 commit comments

Comments
 (0)