From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Anton Moryakov <ant.v.moryakov@gmail.com>,
<linux-mtd@lists.infradead.org>
Subject: Re: [PATCH mtd-utils] misc-utils: add missing error handling for 'bam' allocation in ftl_check.c
Date: Fri, 20 Dec 2024 09:11:03 +0800 [thread overview]
Message-ID: <938073ca-f4b2-c17f-2d30-5699b1293749@huawei.com> (raw)
In-Reply-To: <20241219135103.712032-1-ant.v.moryakov@gmail.com>
在 2024/12/19 21:51, Anton Moryakov 写道:
> Corrections explained:
> Added robust handling for malloc() failure by checking the returnvalueand providing a clear error message.
>
> Triggers found by static analyzer Svace.
>
> Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
>
> ---
> misc-utils/ftl_check.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/misc-utils/ftl_check.c b/misc-utils/ftl_check.c
> index 5b2dae5..fe43a24 100644
> --- a/misc-utils/ftl_check.c
> +++ b/misc-utils/ftl_check.c
> @@ -120,8 +120,17 @@ static void check_partition(int fd)
>
> /* Create basic block allocation table for control blocks */
> nbam = (mtd.erasesize >> hdr.BlockSize);
> bam = malloc(nbam * sizeof(u_int));
> + if (!bam) {
> + perror("malloc failed");
> + return;
> + }
>
> for (i = 0; i < le16_to_cpu(hdr.NumEraseUnits); i++) {
> if (lseek(fd, (i << hdr.EraseUnitSize), SEEK_SET) == -1) {
> perror("seek failed");
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2024-12-20 1:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 13:51 [PATCH mtd-utils] misc-utils: add missing error handling for 'bam' allocation in ftl_check.c Anton Moryakov
2024-12-20 1:11 ` 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=938073ca-f4b2-c17f-2d30-5699b1293749@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=ant.v.moryakov@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/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