Skip to contentSkip to conversation

pinctrl: free if of_get_parent fails to get the parent node

PATCH Superseded Devendra Naga 3 participants 3 messages Jun 2, 2012 – Jun 7, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 pinctrl: free if of_get_parent fails to get the parent node

of_get_parent can return null if no parent node found, so the allocated new_map should be freed.

---
 drivers/pinctrl/pinctrl-imx.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-imx.c +3 -1
index 553ed95..82c1d80 100644
@@ -173,8 +173,10 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	/* create mux map */
 	parent = of_get_parent(np);
-	if (!parent)
+	if (!parent) {
+		kfree(new_map);
 		return -EINVAL;
+	}
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 7 lines · Devendra Naga

of_get_parent can return null if no parent node found, so the allocated new_map should be freed.

---
 drivers/pinctrl/pinctrl-imx.c |    4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)

Shawn/Dong can you ACK/NACK this patch so I can apply it to pinctrl? Alternatively you can push it through the i.MX tree if need be, Acked-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

Acked-by on v1 2/2
#2 lore raw
In reply to Devendra Naga
Quoted 8 lines · Devendra Naga

of_get_parent can return null if no parent node found, so the allocated new_map should be freed.

---
 drivers/pinctrl/pinctrl-imx.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Thanks for fixing.

Regards
Dong Aisheng

Quoted 25 lines
drivers/pinctrl/pinctrl-imx.c +3 -1
index 553ed95..82c1d80 100644
@@ -173,8 +173,10 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	/* create mux map */
 	parent = of_get_parent(np);
-	if (!parent)
+	if (!parent) {
+		kfree(new_map);
 		return -EINVAL;
+	}
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
Signature · 7 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/