From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: zhangchujun <zhangchujun@cmss.chinamobile.com>
Cc: platform-driver-x86@vger.kernel.org, Dell.Client.Kernel@dell.com
Subject: Re: [PATCH] tools: wmi: fix free of uninitialized buffer
Date: Fri, 4 Dec 2026 19:33:33 +0200 (EET) [thread overview]
Message-ID: <a0002783-490a-b240-ff47-78755566f4c8@linux.intel.com> (raw)
In-Reply-To: <20261104080403.2100-1-zhangchujun@cmss.chinamobile.com>
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.
next prev parent reply other threads:[~2026-12-04 17:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 8:04 [PATCH] tools: wmi: fix free of uninitialized buffer zhangchujun
2026-12-04 17:33 ` Ilpo Järvinen [this message]
2026-12-04 17:37 ` Ilpo Järvinen
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=a0002783-490a-b240-ff47-78755566f4c8@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Dell.Client.Kernel@dell.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=zhangchujun@cmss.chinamobile.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 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.