Messages in this thread | | | Date | Fri, 14 Oct 2022 14:03:34 +0100 | From | Matthew Wilcox <> | Subject | Re: [PATCH] unicode: mkutf8data: Add malloc return value detection |
| |
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.
| |