From: Zhihao Cheng Date: Tue, 7 Jul 2020 13:41:01 +0000 (+0800) Subject: ubi: fastmap: Free fastmap next anchor peb during detach X-Git-Tag: v5.10.7~1881^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c3fc1a3919e35a9d8157ed3ae6fd0a478293ba2c;p=platform%2Fkernel%2Flinux-rpi.git ubi: fastmap: Free fastmap next anchor peb during detach ubi_wl_entry related with the fm_next_anchor PEB is not freed during detach, which causes a memory leak. Don't forget to release fm_next_anchor PEB while detaching ubi from mtd when CONFIG_MTD_UBI_FASTMAP is enabled. Signed-off-by: Zhihao Cheng Fixes: 4b68bf9a69d22d ("ubi: Select fastmap anchor PEBs considering...") Signed-off-by: Richard Weinberger --- diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c index 83afc00..28f55f9 100644 --- a/drivers/mtd/ubi/fastmap-wl.c +++ b/drivers/mtd/ubi/fastmap-wl.c @@ -381,6 +381,11 @@ static void ubi_fastmap_close(struct ubi_device *ubi) ubi->fm_anchor = NULL; } + if (ubi->fm_next_anchor) { + return_unused_peb(ubi, ubi->fm_next_anchor); + ubi->fm_next_anchor = NULL; + } + if (ubi->fm) { for (i = 0; i < ubi->fm->used_blocks; i++) kfree(ubi->fm->e[i]);