mtd: sm_ftl: Fix memory leak in sm_init_zone() error path
authorWenwen Wang <wenwen@cs.uga.edu>
Sun, 18 Aug 2019 16:36:44 +0000 (11:36 -0500)
committerRichard Weinberger <richard@nod.at>
Sun, 15 Sep 2019 21:50:50 +0000 (23:50 +0200)
commit137e92fd14959506269d58e08dae35c0bb745211
treeb6582b3f91d2159b229ad34898f99ca30a8494fe
parenta3f12a35c91d649406c94fd791c8d6d1c3c29b6e
mtd: sm_ftl: Fix memory leak in sm_init_zone() error path

In sm_init_zone(), 'zone->lba_to_phys_table' is allocated through
kmalloc_array() and 'zone->free_sectors' is allocated in kfifo_alloc()
respectively. However, they are not deallocated in the following execution
if sm_read_sector() fails, leading to memory leaks. To fix this issue, free
them before returning -EIO.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/sm_ftl.c