[PATCH 2/2] pinctrl: rp1: use pinctrl_utils_free_map() for map cleanup
From: Xiaolei Wang
Date: Wed Nov 25 2026 - 22:54:42 EST
The rp1 driver open-codes a dt_free_map callback that frees the config
arrays of pinctrl maps and the map array itself. This duplicates
pinctrl_utils_free_map(), which the pinctrl core already provides for
exactly this purpose.
The local copy only handles CONFIGS_PIN maps. Because the driver can
delegate map creation to the generic pinconf DT parser, CONFIGS_GROUP
maps may also be produced, and their config arrays would be leaked by
the open-coded version. The core helper handles both types, so using
it removes the duplicate code and closes that leak at the same time.
Signed-off-by: Xiaolei Wang <wangxiaolei01@xxxxxxxxxxx>
---
drivers/pinctrl/pinctrl-rp1.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-rp1.c b/drivers/pinctrl/pinctrl-rp1.c
index 99566a25ecb4..bf2c300eef29 100644
--- a/drivers/pinctrl/pinctrl-rp1.c
+++ b/drivers/pinctrl/pinctrl-rp1.c
@@ -1089,18 +1089,6 @@ static void rp1_pctl_pin_dbg_show(struct pinctrl_dev *pctldev,
irq, irq_type_names[pin->irq_type]);
}
-static void rp1_pctl_dt_free_map(struct pinctrl_dev *pctldev,
- struct pinctrl_map *maps, unsigned int num_maps)
-{
- int i;
-
- for (i = 0; i < num_maps; i++)
- if (maps[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
- kfree(maps[i].data.configs.configs);
-
- kfree(maps);
-}
-
static int rp1_pctl_legacy_map_func(struct rp1_pinctrl *pc,
struct device_node *np, u32 pin, u32 fnum,
struct pinctrl_map *maps,
@@ -1286,7 +1274,7 @@ static int rp1_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
return 0;
out:
- rp1_pctl_dt_free_map(pctldev, maps, reserved_maps);
+ pinctrl_utils_free_map(pctldev, maps, reserved_maps);
return err;
}
@@ -1296,7 +1284,7 @@ static const struct pinctrl_ops rp1_pctl_ops = {
.get_group_pins = rp1_pctl_get_group_pins,
.pin_dbg_show = rp1_pctl_pin_dbg_show,
.dt_node_to_map = rp1_pctl_dt_node_to_map,
- .dt_free_map = rp1_pctl_dt_free_map,
+ .dt_free_map = pinctrl_utils_free_map,
};
static int rp1_pmx_free(struct pinctrl_dev *pctldev, unsigned int offset)
--
2.34.1