From: Matthew Wilcox <willy@infradead.org>
To: Li zeming <zeming@nfschina.com>
Cc: krisman@collabora.com, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] unicode: mkutf8data: Add malloc return value detection
Date: Fri, 14 Oct 2022 14:03:34 +0100 [thread overview]
Message-ID: <Y0leJgPmNrqeZP37@casper.infradead.org> (raw)
In-Reply-To: <20221014075710.310943-1-zeming@nfschina.com>
On Fri, Oct 14, 2022 at 03:57:10PM +0800, Li zeming wrote:
> Add the check and judgment statement of malloc return value.
Why? Just to shut up some static checker?
> +++ b/fs/unicode/mkutf8data.c
> @@ -495,6 +495,9 @@ static struct node *alloc_node(struct node *parent)
> int bitnum;
>
> node = malloc(sizeof(*node));
> + if (unlikely(!node))
> + return NULL;
> +
Right, so now alloc_node() can return NULL when it couldn't before.
Look at the callers ...
while (keybits) {
if (!*cursor)
*cursor = alloc_node(node);
node = *cursor;
if (node->nextbyte)
key++;
They're unprepared for alloc_node() to return NULL, so all you've done
is move the crash.
prev parent reply other threads:[~2022-10-14 13:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 7:57 Li zeming
2022-10-14 13:03 ` Matthew Wilcox [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=Y0leJgPmNrqeZP37@casper.infradead.org \
--to=willy@infradead.org \
--cc=krisman@collabora.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zeming@nfschina.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
all inboxes | Powered by JetHome®