Skip to content

Commit a2539b9

Browse files
outman119linusw
authored andcommitted
pinctrl: meson: amlogic-a4: Fix device node reference leak in aml_dt_node_to_map_pinmux()
The of_get_parent() function returns a device_node with an incremented reference count. Use the __free(device_node) cleanup attribute to ensure of_node_put() is automatically called when pnode goes out of scope, fixing a reference leak. Fixes: 6e9be3a ("pinctrl: Add driver support for Amlogic SoCs") Signed-off-by: Felix Gu <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent e9e268e commit a2539b9

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

drivers/pinctrl/meson/pinctrl-amlogic-a4.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,6 @@ static int aml_dt_node_to_map_pinmux(struct pinctrl_dev *pctldev,
679679
unsigned int *num_maps)
680680
{
681681
struct device *dev = pctldev->dev;
682-
struct device_node *pnode;
683682
unsigned long *configs = NULL;
684683
unsigned int num_configs = 0;
685684
struct property *prop;
@@ -693,7 +692,7 @@ static int aml_dt_node_to_map_pinmux(struct pinctrl_dev *pctldev,
693692
return -ENOENT;
694693
}
695694

696-
pnode = of_get_parent(np);
695+
struct device_node *pnode __free(device_node) = of_get_parent(np);
697696
if (!pnode) {
698697
dev_info(dev, "Missing function node\n");
699698
return -EINVAL;

0 commit comments

Comments
 (0)