Skip to content

Commit

Permalink
soc: loongson: loongson2_guts: Add check for devm_kstrdup()
Browse files Browse the repository at this point in the history
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: [email protected]
Signed-off-by: Haoxiang Li <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnd Bergmann <[email protected]>
  • Loading branch information
Haoxiang Li authored and arndb committed Feb 20, 2025
1 parent e1fc410 commit e31e3f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/soc/loongson/loongson2_guts.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ static int loongson2_guts_probe(struct platform_device *pdev)
if (of_property_read_string(root, "model", &machine))
of_property_read_string_index(root, "compatible", 0, &machine);
of_node_put(root);
if (machine)
if (machine) {
soc_dev_attr.machine = devm_kstrdup(dev, machine, GFP_KERNEL);
if (!soc_dev_attr.machine)
return -ENOMEM;
}

svr = loongson2_guts_get_svr();
soc_die = loongson2_soc_die_match(svr, loongson2_soc_die);
Expand Down

0 comments on commit e31e3f6

Please sign in to comment.