DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ethdev: fix build with gcc 5.4.0
@ 2017-07-06 21:45 Thomas Monjalon
  2017-07-13  9:35 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Monjalon @ 2017-07-06 21:45 UTC (permalink / raw)
  To: Matan Azrad; +Cc: dev

Seen on Ubuntu 16.04 with GCC 5.4.0:

lib/librte_ether/rte_ethdev.c: In function 'get_mac_addr_index':
lib/librte_ether/rte_ethdev.c:2369:26: error:
'dev_info.max_mac_addrs' may be used uninitialized in this function

Indeed, rte_eth_dev_info_get() do not write into dev_info
if the port_id is not valid.
So we need to check the port_id and return in case of error.

This extra check should not be needed because the port_id is always
checked before calling get_mac_addr_index().
However it does not hurt.

Reported-by: Matan Azrad <matan@mellanox.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Tested-by: Matan Azrad <matan@mellanox.com>
---
 lib/librte_ether/rte_ethdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 957ae2a17..b038f281b 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2357,6 +2357,7 @@ get_mac_addr_index(uint8_t port_id, const struct ether_addr *addr)
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 	unsigned i;
 
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	rte_eth_dev_info_get(port_id, &dev_info);
 
 	for (i = 0; i < dev_info.max_mac_addrs; i++)
-- 
2.13.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] ethdev: fix build with gcc 5.4.0
  2017-07-06 21:45 [dpdk-dev] [PATCH] ethdev: fix build with gcc 5.4.0 Thomas Monjalon
@ 2017-07-13  9:35 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2017-07-13  9:35 UTC (permalink / raw)
  To: dev, Matan Azrad

06/07/2017 23:45, Thomas Monjalon:
> Seen on Ubuntu 16.04 with GCC 5.4.0:
> 
> lib/librte_ether/rte_ethdev.c: In function 'get_mac_addr_index':
> lib/librte_ether/rte_ethdev.c:2369:26: error:
> 'dev_info.max_mac_addrs' may be used uninitialized in this function
> 
> Indeed, rte_eth_dev_info_get() do not write into dev_info
> if the port_id is not valid.
> So we need to check the port_id and return in case of error.
> 
> This extra check should not be needed because the port_id is always
> checked before calling get_mac_addr_index().
> However it does not hurt.
> 
> Reported-by: Matan Azrad <matan@mellanox.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Tested-by: Matan Azrad <matan@mellanox.com>

Applied

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-13  9:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-06 21:45 [dpdk-dev] [PATCH] ethdev: fix build with gcc 5.4.0 Thomas Monjalon
2017-07-13  9:35 ` Thomas Monjalon

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).