net/netvsc: replace compiler builtin overflow check

'__builtin_add_overflow' added to gcc in version 5, earlier versions
causing build error, like gcc 4.8.5 in RHEL7.

Replaced compiler builtin check with arithmetic check.

Fixes: 7838d3a6ae7a ("net/netvsc: check for overflow on packet info from host")

Reported-by: Raslan Darawsheh <rasland@mellanox.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Tested-by: Raslan Darawsheh <rasland@nvidia.com>
Tested-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
This commit is contained in:
Ferruh Yigit 2020-09-08 11:06:42 +01:00
parent 4016f0bc45
commit d73543b5f4

View File

@ -666,7 +666,7 @@ static void hn_rndis_rx_data(struct hn_rx_queue *rxq,
struct hn_rx_bufinfo *rxb,
void *data, uint32_t dlen)
{
unsigned int data_off, data_len, total_len;
unsigned int data_off, data_len;
unsigned int pktinfo_off, pktinfo_len;
const struct rndis_packet_msg *pkt = data;
struct hn_rxinfo info = {
@ -712,8 +712,8 @@ static void hn_rndis_rx_data(struct hn_rx_queue *rxq,
goto error;
}
if (__builtin_add_overflow(data_off, data_len, &total_len) ||
total_len > pkt->len)
/* overflow check */
if (data_len > data_len + data_off || data_len + data_off > pkt->len)
goto error;
if (unlikely(data_len < RTE_ETHER_HDR_LEN))