Skip to content

Commit 02743c4

Browse files
andy-shevbrgl
authored andcommitted
gpio: mockup: Fix potential resource leakage when register a chip
If creation of software node fails, the locally allocated string array is left unfreed. Free it on error path. Fixes: 6fda593 ("gpio: mockup: Convert to use software nodes") Cc: [email protected] Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent b7df41a commit 02743c4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/gpio/gpio-mockup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,10 @@ static int __init gpio_mockup_register_chip(int idx)
533533
}
534534

535535
fwnode = fwnode_create_software_node(properties, NULL);
536-
if (IS_ERR(fwnode))
536+
if (IS_ERR(fwnode)) {
537+
kfree_strarray(line_names, ngpio);
537538
return PTR_ERR(fwnode);
539+
}
538540

539541
pdevinfo.name = "gpio-mockup";
540542
pdevinfo.id = idx;

0 commit comments

Comments
 (0)