fs/fat: Check malloc return values and fix memory leaks
authorTuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Sat, 30 Sep 2017 23:25:22 +0000 (02:25 +0300)
committerTom Rini <trini@konsulko.com>
Sun, 8 Oct 2017 20:19:56 +0000 (16:19 -0400)
commitaf609e3764ea3ed7c0ccad8e57f9d9671c81c3e8
treea680cc06ac395af2a49a48b5d5107e5de4b084e7
parent09fa964bba80c45432660f0e64362181900a5aef
fs/fat: Check malloc return values and fix memory leaks

Check malloc() return values and properly unwind on errors so
memory allocated for fat_itr structures get freed properly.

Also fixes a leak of fsdata.fatbuf in fat_size().

Fixes: 2460098cffacd1 ("fs/fat: Reduce stack usage")
Reported-by: Coverity (CID: 167225, 167233, 167234)
Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Reviewed-by: Tom Rini <trini@konsulko.com>
fs/fat/fat.c