From: Jakub Kicinski <kuba@kernel.org>
To: Thaison Phan <thaisonphan@google.com>
Cc: "Donald Hunter" <donald.hunter@gmail.com>,
"David S . Miller " <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Fengyuan Gong" <gfengyuan@google.com>,
"Stan Iliev" <stani@google.com>,
"Asbjørn Sloth Tønnesen" <ast@fiberby.net>,
"Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] tools: ynl: check alloc fails in generated code
Date: Tue, 4 Aug 2026 14:33:59 -0700 [thread overview]
Message-ID: <20260804143359.702b0237@kernel.org> (raw)
In-Reply-To: <20260803201652.2752685-3-thaisonphan@google.com>
On Mon, 3 Aug 2026 20:16:52 +0000 Thaison Phan wrote:
> def _setter_lines(self, ri, member, presence):
> - return [f"{presence} = len;",
> - f"{member} = malloc({presence});",
> + return [f"{member} = malloc(len);",
> + f"if (!{member})",
> + "return;",
> + f"{presence} = len;",
> f'memcpy({member}, {self.c_name}, {presence});']
Silently eating errors in setters does not seem great, better to crash
and make it clear than things are not working than have a silently
misconfigured system?
AI also points out that setters are preceded by a free (in case we're
replacing existing attr, multiple sets on a single attr are allowed)
So if alloc fails we'll end up with NULL ptr and len from previous
allocation.
Maybe tackle the setters in a separate patch, and keep patch 2 scoped
to the easier case?
--
pw-bot: cr
prev parent reply other threads:[~2026-08-04 21:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 20:16 [PATCH net-next 0/2] tools: ynl: update NULL pointer handling in generated code Thaison Phan
2026-08-03 20:16 ` [PATCH net-next 1/2] tools: ynl: check for null ptr on dump free Thaison Phan
2026-08-04 21:25 ` Jakub Kicinski
2026-08-03 20:16 ` [PATCH net-next 2/2] tools: ynl: check alloc fails in generated code Thaison Phan
2026-08-04 21:33 ` Jakub Kicinski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260804143359.702b0237@kernel.org \
--to=kuba@kernel.org \
--cc=ast@fiberby.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=gfengyuan@google.com \
--cc=horms@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matttbe@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stani@google.com \
--cc=thaisonphan@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox