]> 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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Sep 2025 08:58:52 +0000 (10:58 +0200)
commit 51adb03e6b865c0c6790f29659ff52d56742de2e 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>
arch/loongarch/kernel/env.c

index 6d56a463b091c0f6069380565ea6e0883e7571a6..5cc527a41a9715a73973dfc708d10def4f721d3d 100644 (file)
@@ -70,6 +70,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);
 }