Re: [PATCH] unicode: mkutf8data: Add malloc return value detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux