Skip to content

Commit

Permalink
gpio: mockup: Fix potential resource leakage when register a chip
Browse files Browse the repository at this point in the history
commit 02743c4 upstream.

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: stable@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
andy-shev authored and gregkh committed Sep 28, 2022
1 parent af0bfab commit 41f8570
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpio/gpio-mockup.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,10 @@ static int __init gpio_mockup_register_chip(int idx)
}

fwnode = fwnode_create_software_node(properties, NULL);
if (IS_ERR(fwnode))
if (IS_ERR(fwnode)) {
kfree_strarray(line_names, ngpio);
return PTR_ERR(fwnode);
}

pdevinfo.name = "gpio-mockup";
pdevinfo.id = idx;
Expand Down

0 comments on commit 41f8570

Please sign in to comment.