From: Nishka Dasgupta Date: Sat, 6 Jul 2019 13:19:11 +0000 (+0530) Subject: i2c: fsi: Add of_put_node() before break X-Git-Tag: v5.4-rc1~51^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a321b97368aa0567f238207eeb19cc8cbb6a7e2;p=platform%2Fkernel%2Flinux-rpi.git i2c: fsi: 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. Signed-off-by: Nishka Dasgupta Reviewed-by: Eddie James Signed-off-by: Wolfram Sang --- diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index da5eb39..e0c25692 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -707,8 +707,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;