lkml.org 
[lkml]   [2022]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.

\
 
 \ /
  Last update: 2022-10-14 15:04    [W:0.043 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site