i2c: busses: i2c-fsi.c: Add of_put_node() before break
Subsystems (2)
PATCH 1/1 i2c: busses: i2c-fsi.c: Add of_put_node() before break
Each iteration of for_each_available_childe_of_node puts the previous node, but in the case of a break from the middle of the loop, there is no put, thus causing a memory leak. Add an of_node_put before the break.
Issue found with Coccinelle.
--- drivers/i2c/busses/i2c-fsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-fsi.c +3 -1
@@ -685,8 +685,10 @@ static int fsi_i2c_probe(struct device *dev)continue ; port =kzalloc (sizeof (*port),GFP_KERNEL ); -if (!port) +if (!port) { +of_node_put (np);break ; + } port->master = i2c; port->port = port_no;
Signature · 1 line
2.19.1
Quoted 8 lines · Nishka Dasgupta
Each iteration of
for_each_available_childe_of_nodeputs the previous node, but in the case of a break from the middle of the loop, there is no put, thus causing a memory leak. Add anof_node_putbefore the break.
Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>---
Eddie, are you okay with this change?
Quoted 22 lines
drivers/i2c/busses/i2c-fsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/i2c/busses/i2c-fsi.c +3
-1@@ -685,8 +685,10 @@ static int fsi_i2c_probe(struct device *dev)continue ; port =kzalloc (sizeof (*port),GFP_KERNEL ); -if (!port) +if (!port) { +of_node_put (np);break ; + } port->master = i2c; port->port = port_no;Signature · 1 line
2.19.1
Eddie James
Reviewed-byQuoted 10 lines · Wolfram Sang
Quoted 8 lines · Nishka Dasgupta
Each iteration of
for_each_available_childe_of_nodeputs the previous node, but in the case of a break from the middle of the loop, there is no put, thus causing a memory leak. Add anof_node_putbefore the break.
Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>---
Eddie, are you okay with this change?
Yes, sorry must have missed this when it first came in.
Thanks.
Quoted 23 lines
Quoted 23 lines
drivers/i2c/busses/i2c-fsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/i2c/busses/i2c-fsi.c +3
-1@@ -685,8 +685,10 @@ static int fsi_i2c_probe(struct device *dev)continue ; port =kzalloc (sizeof (*port),GFP_KERNEL ); -if (!port) +if (!port) { +of_node_put (np);break ; + } port->master = i2c; port->port = port_no;Signature · 1 line
2.19.1
Wolfram Sang
AppliedQuoted 7 lines · Nishka Dasgupta
Each iteration of
for_each_available_childe_of_nodeputs the previous node, but in the case of a break from the middle of the loop, there is no put, thus causing a memory leak. Add anof_node_putbefore the break.
Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>
Applied to for-next, thanks!