Skip to content

Commit 51adb03

Browse files
Tao Cuichenhuacai
authored andcommitted
LoongArch: Check the return value when creating kobj
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>
1 parent a9d1343 commit 51adb03

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
@@ -109,6 +109,8 @@ static int __init boardinfo_init(void)
109109
struct kobject *loongson_kobj;
110110

111111
loongson_kobj = kobject_create_and_add("loongson", firmware_kobj);
112+
if (!loongson_kobj)
113+
return -ENOMEM;
112114

113115
return sysfs_create_file(loongson_kobj, &boardinfo_attr.attr);
114116
}

0 commit comments

Comments
 (0)