Skip to content

Commit e31e3f6

Browse files
Haoxiang Liarndb
authored andcommitted
soc: loongson: loongson2_guts: Add check for devm_kstrdup()
Add check for the return value of devm_kstrdup() in loongson2_guts_probe() to catch potential exception. Fixes: b82621a ("soc: loongson: add GUTS driver for loongson-2 platforms") Cc: stable@vger.kernel.org Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com> Link: https://lore.kernel.org/r/20250220081714.2676828-1-haoxiang_li2024@163.com Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent e1fc410 commit e31e3f6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/soc/loongson/loongson2_guts.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ static int loongson2_guts_probe(struct platform_device *pdev)
114114
if (of_property_read_string(root, "model", &machine))
115115
of_property_read_string_index(root, "compatible", 0, &machine);
116116
of_node_put(root);
117-
if (machine)
117+
if (machine) {
118118
soc_dev_attr.machine = devm_kstrdup(dev, machine, GFP_KERNEL);
119+
if (!soc_dev_attr.machine)
120+
return -ENOMEM;
121+
}
119122

120123
svr = loongson2_guts_get_svr();
121124
soc_die = loongson2_soc_die_match(svr, loongson2_soc_die);

0 commit comments

Comments
 (0)