* [PATCH] tools: wmi: fix free of uninitialized buffer
@ 2026-11-04 8:04 zhangchujun
2026-12-04 17:33 ` Ilpo Järvinen
2026-12-04 17:37 ` Ilpo Järvinen
0 siblings, 2 replies; 3+ messages in thread
From: zhangchujun @ 2026-11-04 8:04 UTC (permalink / raw)
To: platform-driver-x86; +Cc: Dell.Client.Kernel, zhangchujun
main() declares the buffer pointer without initializing it. When
query_buffer_size() fails (e.g. the ioctl device node does not
exist) or reports a size of zero, the code jumps to the out
label and calls free() on the uninitialized pointer, which is
undefined behaviour.
Initialize buffer to NULL so that the error path is a harmless
free(NULL).
Signed-off-by: zhangchujun <zhangchujun@cmss.chinamobile.com>
diff --git a/tools/wmi/dell-smbios-example.c b/tools/wmi/dell-smbios-example.c
index 1f3e7ab14b68..57a873d94fa9 100644
--- a/tools/wmi/dell-smbios-example.c
+++ b/tools/wmi/dell-smbios-example.c
@@ -154,7 +154,7 @@ static int query_buffer_size(__u64 *buffer_size)
int main(void)
{
- struct dell_wmi_smbios_buffer *buffer;
+ struct dell_wmi_smbios_buffer *buffer = NULL;
int ret;
__u64 value = 0;
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] tools: wmi: fix free of uninitialized buffer
2026-11-04 8:04 [PATCH] tools: wmi: fix free of uninitialized buffer zhangchujun
@ 2026-12-04 17:33 ` Ilpo Järvinen
2026-12-04 17:37 ` Ilpo Järvinen
1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2026-12-04 17:33 UTC (permalink / raw)
To: zhangchujun; +Cc: platform-driver-x86, Dell.Client.Kernel
On Wed, 4 Nov 2026, zhangchujun wrote:
> main() declares the buffer pointer without initializing it. When
> query_buffer_size() fails (e.g. the ioctl device node does not
> exist) or reports a size of zero, the code jumps to the out
> label and calls free() on the uninitialized pointer, which is
> undefined behaviour.
>
> Initialize buffer to NULL so that the error path is a harmless
> free(NULL).
>
> Signed-off-by: zhangchujun <zhangchujun@cmss.chinamobile.com>
>
> diff --git a/tools/wmi/dell-smbios-example.c b/tools/wmi/dell-smbios-example.c
> index 1f3e7ab14b68..57a873d94fa9 100644
> --- a/tools/wmi/dell-smbios-example.c
> +++ b/tools/wmi/dell-smbios-example.c
> @@ -154,7 +154,7 @@ static int query_buffer_size(__u64 *buffer_size)
>
> int main(void)
> {
> - struct dell_wmi_smbios_buffer *buffer;
> + struct dell_wmi_smbios_buffer *buffer = NULL;
Fix the goto instead to avoid the free() call like rollback paths normally
work.
--
i.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] tools: wmi: fix free of uninitialized buffer
2026-11-04 8:04 [PATCH] tools: wmi: fix free of uninitialized buffer zhangchujun
2026-12-04 17:33 ` Ilpo Järvinen
@ 2026-12-04 17:37 ` Ilpo Järvinen
1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2026-12-04 17:37 UTC (permalink / raw)
To: zhangchujun; +Cc: platform-driver-x86, Dell.Client.Kernel
On Wed, 4 Nov 2026, zhangchujun wrote:
> main() declares the buffer pointer without initializing it. When
> query_buffer_size() fails (e.g. the ioctl device node does not
> exist) or reports a size of zero, the code jumps to the out
> label and calls free() on the uninitialized pointer, which is
> undefined behaviour.
>
> Initialize buffer to NULL so that the error path is a harmless
> free(NULL).
>
> Signed-off-by: zhangchujun <zhangchujun@cmss.chinamobile.com>
And is this the form you'd normally use for your name? Think of it as
signing a contract or a document.
For more information, see:
Documentation/process/submitting-patches.rst
--
i.
> diff --git a/tools/wmi/dell-smbios-example.c b/tools/wmi/dell-smbios-example.c
> index 1f3e7ab14b68..57a873d94fa9 100644
> --- a/tools/wmi/dell-smbios-example.c
> +++ b/tools/wmi/dell-smbios-example.c
> @@ -154,7 +154,7 @@ static int query_buffer_size(__u64 *buffer_size)
>
> int main(void)
> {
> - struct dell_wmi_smbios_buffer *buffer;
> + struct dell_wmi_smbios_buffer *buffer = NULL;
> int ret;
> __u64 value = 0;
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-04 17:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 8:04 [PATCH] tools: wmi: fix free of uninitialized buffer zhangchujun
2026-12-04 17:33 ` Ilpo Järvinen
2026-12-04 17:37 ` Ilpo Järvinen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.