Skip to content

Commit 66a7c84

Browse files
Colin Ian KingWolfram Sang
authored andcommitted
i2c: i2c-boardinfo: fix memory leaks on devinfo
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: 4124c4e ("i2c: allow attaching IRQ resources to i2c_board_info") Fixes: 0daaf99 ("i2c: copy device properties when using i2c_register_board_info()") Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 6e0c950 commit 66a7c84

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/i2c/i2c-boardinfo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsig
8686
property_entries_dup(info->properties);
8787
if (IS_ERR(devinfo->board_info.properties)) {
8888
status = PTR_ERR(devinfo->board_info.properties);
89+
kfree(devinfo);
8990
break;
9091
}
9192
}
@@ -98,6 +99,7 @@ int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsig
9899
GFP_KERNEL);
99100
if (!devinfo->board_info.resources) {
100101
status = -ENOMEM;
102+
kfree(devinfo);
101103
break;
102104
}
103105
}

0 commit comments

Comments
 (0)