[PATCH] ubi: fastmap: fix ubi->fm memory leak
Liyuan Pang
pangliyuan1 at huawei.com
Thu Nov 6 18:11:37 PST 2025
On Thu, 6 Nov 2025 16:16:05 +0100, Markus Elfring wrote:
>â¦
>> +++ b/drivers/mtd/ubi/fastmap.c
>> @@ -1644,3 +1644,15 @@ int ubi_update_fastmap(struct ubi_device *ubi)
>â¦
>> +void ubi_free_fastmap(struct ubi_device *ubi)
>> +{
>> + int i;
>> +
>> + if (ubi->fm) {
> + for (i = 0; i < ubi->fm->used_blocks; i++)
> + kmem_cache_free(ubi_wl_entry_slab, ubi->fm->e[i]);
>â¦
> + }
> +}
>â¦
>
> May the local variable âiâ be defined in the loop header?
I think it's better to leave it as it is, most of the code in
ubi defines variables outside the loop header, and defining
"i" in the loop header may cause compilation error in some old
kernel versions that use C89.
Regards,
Liyuan
More information about the linux-arm-kernel
mailing list