of: reserved-mem: Warn for missing initfn in __reservedmem_of_table
For the data in __reservedmem_of_table, its function pointer initfn might be NULL. However, __reserved_mem_init_node() only considers non-NULL cases and ignores NULL function pointers.
Therefore, a check for the possibility of initfn being NULL has been added here, along with skipping the initfn() and issuing a warning.
To: Rob Herring <robh@kernel.org> To: Saravana Kannan <saravanak@google.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Liya Huang <1425075683@qq.com>
$ b4 send --web-auth-new Will submit a new email authorization request to: Endpoint: https://lkml.kernel.org/_b4_submit Name: Konstantin Ryabitsev Identity: icon@mricon.com Selector: 20221221 Pubkey: ed25519:24L8+ejW6PwbTbrJ/uT8HmSM8XkvGGtjTZ6NftSSI6I= --- Press Enter to confirm or Ctrl-C to abort Submitting new auth request to https://lkml.kernel.org/_b4_submit --- Challenge generated and sent to icon@mricon.com Once you receive it, run b4 send --web-auth-verify [challenge-string]
$ b4 send --web-auth-verify 897851db-9b84-4117-9d82-1d970f9df5f8 Signing challenge Submitting verification to https://lkml.kernel.org/_b4_submit --- Challenge successfully verified for icon@mricon.com You may now use this endpoint for submitting patches.
9 . 或者,设置你的 [sendemail] 部分
9.1 b4 prep –check
10. 反射邮件给自己
b4 send –reflect
这是在发送您的贡献之前要执行的最后一个步骤。注意,这将填充所有消息的 To: 和 Cc: 标头,以实际收件人信息,但它实际上不会向他们发送邮件,只会向您自己发送。邮件服务器实际上不会关注那些标头——对他们来说,唯一重要的是在协商的 RCPT TO 外部信封中指定的内容。
Subject: Re: [PATCH] of: reserved-mem: Warn for missing initfn in __reservedmem_of_table
> On Tue, Apr 15, 2025 at 9:16 AM Liya Huang <1425075683@qq.com> wrote: > > > > For the data in __reservedmem_of_table, its function pointer initfn might > > be NULL. However, __reserved_mem_init_node() only considers non-NULL cases > > and ignores NULL function pointers. > > If initfn is NULL, there's no point to the entry and that's a bug. > Unless you have a build time check, there's no point to add this. > > Rob
Thank you for your response. Based on your suggestion, I have made the modifications and used static_assert() to perform the check at compile time. The specific code is as follows. Could you please review whether this modification is reasonable? If it is acceptable, I will proceed with submitting the patch.
I did not find any usage of static_assert() for null pointer checks in the kernel code. Additionally, BUILD_BUG_ON() cannot be used globally.