i2c: i2c-boardinfo: fix memory leaks on devinfo
authorColin Ian King <colin.king@canonical.com>
Wed, 22 Nov 2017 17:52:24 +0000 (17:52 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Feb 2018 16:39:07 +0000 (17:39 +0100)
commit53c045c6d07d78bf0d547352df184c250cc29fe3
tree644ed743560838878df5d9b21a6d16dede285464
parent30ac846da3600e299cd470ade18e1e859b6a41f8
i2c: i2c-boardinfo: fix memory leaks on devinfo

[ Upstream commit 66a7c84d677e8e4a5a2ef4afdb9bd52e1399a866 ]

Currently when an error occurs devinfo is still allocated but is
unused when the error exit paths break out of the for-loop. Fix
this by kfree'ing devinfo to avoid the leak.

Detected by CoverityScan, CID#1416590 ("Resource Leak")

Fixes: 4124c4eba402 ("i2c: allow attaching IRQ resources to i2c_board_info")
Fixes: 0daaf99d8424 ("i2c: copy device properties when using i2c_register_board_info()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/i2c/i2c-boardinfo.c