Linux-mtd Archive mirror
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Fedor Pchelkin <pchelkin@ispras.ru>, Richard Weinberger <richard@nod.at>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Artem Bityutskiy <artem.bityutskiy@linux.intel.com>,
	<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	Alexey Khoroshilov <khoroshilov@ispras.ru>,
	<lvc-project@linuxtesting.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH] ubi: eba: properly rollback inside self_check_eba
Date: Fri, 1 Mar 2024 09:23:58 +0800	[thread overview]
Message-ID: <1421503e-b1d2-87f2-e33e-1a0428100be2@huawei.com> (raw)
In-Reply-To: <20240229204237.30453-1-pchelkin@ispras.ru>

在 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@vger.kernel.org
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
> ---
>   drivers/mtd/ubi/eba.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.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;
>   
> 


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2024-03-01  1:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 20:42 [PATCH] ubi: eba: properly rollback inside self_check_eba Fedor Pchelkin
2024-03-01  1:23 ` Zhihao Cheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421503e-b1d2-87f2-e33e-1a0428100be2@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=khoroshilov@ispras.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=pchelkin@ispras.ru \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).