linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] unicode: mkutf8data: Add malloc allocation check
@ 2022-10-24  4:51 Li kunyu
  2022-10-24  7:59 ` Bagas Sanjaya
  0 siblings, 1 reply; 2+ messages in thread
From: Li kunyu @ 2022-10-24  4:51 UTC (permalink / raw)
  To: krisman; +Cc: linux-fsdevel, linux-kernel, Li kunyu

Increase the judgment of malloc allocation, and return NULL if the
condition is met.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 fs/unicode/mkutf8data.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/unicode/mkutf8data.c b/fs/unicode/mkutf8data.c
index e06404a6b106..a929ddf1438c 100644
--- a/fs/unicode/mkutf8data.c
+++ b/fs/unicode/mkutf8data.c
@@ -495,6 +495,9 @@ static struct node *alloc_node(struct node *parent)
 	int bitnum;
 
 	node = malloc(sizeof(*node));
+	if (!node)
+		return NULL;
+
 	node->left = node->right = NULL;
 	node->parent = parent;
 	node->leftnode = NODE;
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] unicode: mkutf8data: Add malloc allocation check
  2022-10-24  4:51 [PATCH 2/2] unicode: mkutf8data: Add malloc allocation check Li kunyu
@ 2022-10-24  7:59 ` Bagas Sanjaya
  0 siblings, 0 replies; 2+ messages in thread
From: Bagas Sanjaya @ 2022-10-24  7:59 UTC (permalink / raw)
  To: Li kunyu; +Cc: krisman, linux-fsdevel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 942 bytes --]

On Mon, Oct 24, 2022 at 12:51:50PM +0800, Li kunyu wrote:
> Increase the judgment of malloc allocation, and return NULL if the
> condition is met.
> 
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
>  fs/unicode/mkutf8data.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/unicode/mkutf8data.c b/fs/unicode/mkutf8data.c
> index e06404a6b106..a929ddf1438c 100644
> --- a/fs/unicode/mkutf8data.c
> +++ b/fs/unicode/mkutf8data.c
> @@ -495,6 +495,9 @@ static struct node *alloc_node(struct node *parent)
>  	int bitnum;
>  
>  	node = malloc(sizeof(*node));
> +	if (!node)
> +		return NULL;
> +
>  	node->left = node->right = NULL;
>  	node->parent = parent;
>  	node->leftnode = NODE;

What?

This is not "malloc judgement", but rather return NULL if node fails to
allocate.

Please, please reword the patch description.

Thanks.

-- 
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-24  7:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-24  4:51 [PATCH 2/2] unicode: mkutf8data: Add malloc allocation check Li kunyu
2022-10-24  7:59 ` Bagas Sanjaya

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).