]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
LoongArch: Check the return value when creating kobj
authorTao Cui <cuitao@kylinos.cn>
Thu, 18 Sep 2025 11:44:04 +0000 (19:44 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Thu, 18 Sep 2025 11:44:04 +0000 (19:44 +0800)
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>
arch/loongarch/kernel/env.c

index c0a5dc9aeae2871223b6e5efc88a9137c11378d9..be309a71f204910dba1af5ecbc1c2a042d1f3179 100644 (file)
@@ -109,6 +109,8 @@ static int __init boardinfo_init(void)
        struct kobject *loongson_kobj;
 
        loongson_kobj = kobject_create_and_add("loongson", firmware_kobj);
+       if (!loongson_kobj)
+               return -ENOMEM;
 
        return sysfs_create_file(loongson_kobj, &boardinfo_attr.attr);
 }