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: [email protected] Signed-off-by: Tao Cui <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent a9d1343 commit 51adb03

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • arch/loongarch/kernel

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)