From: Paolo Bonzini <pbonzini@redhat.com>
To: Shannon Zhao <zhaoshenglong@huawei.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, hangaohuai@huawei.com,
qemu-trivial@nongnu.org, mjt@tls.msk.ru,
peter.huangpeng@huawei.com, shannon.zhao@linaro.org,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] hw/net/e1000: fix integer endianness
Date: Fri, 13 Mar 2015 13:51:34 +0100 [thread overview]
Message-ID: <5502DD56.6080103@redhat.com> (raw)
In-Reply-To: <1426224119-8352-1-git-send-email-zhaoshenglong@huawei.com>
On 13/03/2015 06:21, Shannon Zhao wrote:
> It's detected by coverity.In is_vlan_packet s->mac_reg[VET] is
> unsigned int but is dereferenced as a narrower unsigned short.
> This may lead to unexpected results depending on machine
> endianness.
Sounds good. CCing Stefan, net/ maintainer.
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> hw/net/e1000.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> index a207e21..59d73cd 100644
> --- a/hw/net/e1000.c
> +++ b/hw/net/e1000.c
> @@ -578,7 +578,7 @@ static inline int
> is_vlan_packet(E1000State *s, const uint8_t *buf)
> {
> return (be16_to_cpup((uint16_t *)(buf + 12)) ==
> - le16_to_cpup((uint16_t *)(s->mac_reg + VET)));
> + le16_to_cpu(s->mac_reg[VET]));
> }
>
> static inline int
> @@ -711,7 +711,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
> (tp->cptse || txd_lower & E1000_TXD_CMD_EOP)) {
> tp->vlan_needed = 1;
> stw_be_p(tp->vlan_header,
> - le16_to_cpup((uint16_t *)(s->mac_reg + VET)));
> + le16_to_cpu(s->mac_reg[VET]));
> stw_be_p(tp->vlan_header + 2,
> le16_to_cpu(dp->upper.fields.special));
> }
>
next prev parent reply other threads:[~2015-03-13 12:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 5:21 [Qemu-devel] [PATCH] hw/net/e1000: fix integer endianness Shannon Zhao
2015-03-13 12:51 ` Paolo Bonzini [this message]
2015-03-17 17:05 ` Stefan Hajnoczi
2015-03-18 1:28 ` Shannon Zhao
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=5502DD56.6080103@redhat.com \
--to=pbonzini@redhat.com \
--cc=hangaohuai@huawei.com \
--cc=mjt@tls.msk.ru \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=shannon.zhao@linaro.org \
--cc=stefanha@redhat.com \
--cc=zhaoshenglong@huawei.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;
as well as URLs for NNTP newsgroup(s).