[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1421503e-b1d2-87f2-e33e-1a0428100be2@huawei.com>
Date: Fri, 1 Mar 2024 09:23:58 +0800
From: Zhihao Cheng <chengzhihao1@...wei.com>
To: Fedor Pchelkin <pchelkin@...ras.ru>, Richard Weinberger <richard@....at>
CC: Miquel Raynal <miquel.raynal@...tlin.com>, Vignesh Raghavendra
<vigneshr@...com>, Artem Bityutskiy <artem.bityutskiy@...ux.intel.com>,
<linux-mtd@...ts.infradead.org>, <linux-kernel@...r.kernel.org>, Alexey
Khoroshilov <khoroshilov@...ras.ru>, <lvc-project@...uxtesting.org>,
<stable@...r.kernel.org>
Subject: Re: [PATCH] ubi: eba: properly rollback inside self_check_eba
在 2024/3/1 4:42, Fedor Pchelkin 写道:
> In case of a memory allocation failure in the volumes loop we can only
> process the already allocated scan_eba and fm_eba array elements on the
> error path - others are still uninitialized.
>
> Found by Linux Verification Center (linuxtesting.org).
>
> Fixes: 00abf3041590 ("UBI: Add self_check_eba()")
> Cc: stable@...r.kernel.org
> Signed-off-by: Fedor Pchelkin <pchelkin@...ras.ru>
> ---
> drivers/mtd/ubi/eba.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Zhihao Cheng <chengzhihao1@...wei.com>
>
> diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
> index 8d1f0e05892c..6f5eadb1598d 100644
> --- a/drivers/mtd/ubi/eba.c
> +++ b/drivers/mtd/ubi/eba.c
> @@ -1557,6 +1557,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
> GFP_KERNEL);
> if (!fm_eba[i]) {
> ret = -ENOMEM;
> + kfree(scan_eba[i]);
> goto out_free;
> }
>
> @@ -1592,7 +1593,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
> }
>
> out_free:
> - for (i = 0; i < num_volumes; i++) {
> + while (--i >= 0) {
> if (!ubi->volumes[i])
> continue;
>
>
Powered by blists - more mailing lists