From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
To: Laszlo Ersek <lersek@redhat.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Wu, Hao A" <hao.a.wu@intel.com>, "Ye, Ting" <ting.ye@intel.com>,
"Fu, Siyuan" <siyuan.fu@intel.com>,
"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH v1 1/2] MdeModulePkg/NetLib.h: Fix the possible NULL pointer dereference issue.
Date: Wed, 16 Jan 2019 08:23:05 +0000 [thread overview]
Message-ID: <895558F6EA4E3B41AC93A00D163B727416EC5A13@SHSMSX107.ccr.corp.intel.com> (raw)
In-Reply-To: <953600c3-5346-3d17-cdaa-9574c3d94d14@redhat.com>
Hi Laszlo,
Thanks review the patch.
>
> (1) The linked list from BaseLib (LIST_ENTRY) always has at least one
> element (the head element), and the list is empty if the head element
> points back to itself. In other words, ForwardLink may never be NULL.
>
> So why is it necessary to check against that case here?
>
I agree the ForwardLink in valid LIST_ENTRY can't be NULL. Here, I added the more condition check was considering the possible broken case of the LIST_ENTRY. But I also checked the other usage of *_FOR_EACH_SAFE /*_FOR_EACH, looks never or unnecessary to consider that case.
If so, please drop the series patches and I will create another series patches to remove the unnecessary check after retrieving the value from list Entry.
> (2) If the NULL check is indeed necessary for some reason, then we
> should write
>
> Entry != (ListHead) && Entry != NULL
>
> in the controlling expression. Because, with the comma operator, the
> (Entry != (ListHead)) expression would be evaluated, but its result
> would be ignored.
>
Yes, I was also awared that, so I created patch v2 to fix that:
[edk2] [PATCH v2 1/2] MdeModulePkg/NetLib.h: Fix the possible NULL pointer dereference issue.
Fix the wrong condition in for cycle.
Thanks,
Jiaxin
next prev parent reply other threads:[~2019-01-16 8:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-15 1:26 [PATCH v1 0/2] Fix the possible NULL pointer dereference issue Jiaxin Wu
2019-01-15 1:26 ` [PATCH v1 1/2] MdeModulePkg/NetLib.h: " Jiaxin Wu
2019-01-15 10:29 ` Laszlo Ersek
2019-01-16 8:23 ` Wu, Jiaxin [this message]
2019-01-15 1:26 ` [PATCH v1 2/2] MdeModulePkg/Dhcp4Dxe: Use NET_LIST_FOR_EACH instead of NET_LIST_FOR_EACH_SAFE Jiaxin Wu
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-list 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=895558F6EA4E3B41AC93A00D163B727416EC5A13@SHSMSX107.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/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