Skip to contentSkip to conversation

tools: ynl: handle calloc failure in ynl_ntf_parse

PATCH Applied Triet Hoang 4 participants 4 messages Aug 18 – Aug 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: ynl: handle calloc failure in ynl_ntf_parse

Check the return value of calloc() before dereferencing the allocated response structure in ynl_ntf_parse().

---
 tools/net/ynl/lib/ynl.c | 3 +++
 1 file changed, 3 insertions(+)
tools/net/ynl/lib/ynl.c +3 -0
index 2bcd781111d7..af101544c31a 100644
@@ -889,6 +889,9 @@ static int ynl_ntf_parse(struct ynl_sock *ys, const struct nlmsghdr *nlh)
 		return YNL_PARSE_CB_ERROR;
 
 	rsp = calloc(1, info->alloc_sz);
+	if (!rsp)
+		return YNL_PARSE_CB_ERROR;
+
 	rsp->free = info->free;
 	yarg.data = rsp->data;
 	yarg.rsp_policy = info->policy;
Signature · 1 line
2.53.0
#1 lore raw

Hi Triet,

I think your target tree is net-next, but it's close now. You can repost the patch with the net-next tag after it's reopened.

https://netdev.bots.linux.dev/net-next.html

Thanks
Hangbin

Quoted 25 lines · Triet Hoang

Check the return value of calloc() before dereferencing the allocated response structure in ynl_ntf_parse().

---
 tools/net/ynl/lib/ynl.c | 3 +++
 1 file changed, 3 insertions(+)
tools/net/ynl/lib/ynl.c +3 -0
index 2bcd781111d7..af101544c31a 100644
@@ -889,6 +889,9 @@ static int ynl_ntf_parse(struct ynl_sock *ys, const struct nlmsghdr *nlh)
 		return YNL_PARSE_CB_ERROR;
 
 	rsp = calloc(1, info->alloc_sz);
+	if (!rsp)
+		return YNL_PARSE_CB_ERROR;
+
 	rsp->free = info->free;
 	yarg.data = rsp->data;
 	yarg.rsp_policy = info->policy;
Signature · 1 line
2.53.0
maintainer
#2 lore raw
Quoted 2 lines · On Wed, 19 Aug 2026 16:11:31 +0800 Hangbin Liu wrote:

I think your target tree is net-next, but it's close now. You can repost the patch with the net-next tag after it's reopened.

It's fine, please do not send process related feedback.

#3 lore raw
In reply to Triet Hoang
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 7 lines · On Tue, 18 Aug 2026 13:27:39 +0000 you wrote:

Check the return value of calloc() before dereferencing the allocated response structure in ynl_ntf_parse().

---
 tools/net/ynl/lib/ynl.c | 3 +++
 1 file changed, 3 insertions(+)

Here is the summary with links:
- tools: ynl: handle calloc failure in ynl_ntf_parse

    https://git.kernel.org/netdev/net/c/25b863cd6d12

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html