提交 4e60a250 编写于 作者: S Shannon Zhao 提交者: Stefan Hajnoczi

hw/net/e1000: fix integer endianness

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.
Signed-off-by: NShannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
Message-id: 1426224119-8352-1-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 4ad9e2b3
...@@ -578,7 +578,7 @@ static inline int ...@@ -578,7 +578,7 @@ static inline int
is_vlan_packet(E1000State *s, const uint8_t *buf) is_vlan_packet(E1000State *s, const uint8_t *buf)
{ {
return (be16_to_cpup((uint16_t *)(buf + 12)) == 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 static inline int
...@@ -711,7 +711,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) ...@@ -711,7 +711,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
(tp->cptse || txd_lower & E1000_TXD_CMD_EOP)) { (tp->cptse || txd_lower & E1000_TXD_CMD_EOP)) {
tp->vlan_needed = 1; tp->vlan_needed = 1;
stw_be_p(tp->vlan_header, 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, stw_be_p(tp->vlan_header + 2,
le16_to_cpu(dp->upper.fields.special)); le16_to_cpu(dp->upper.fields.special));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册