summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Rybchenko <arybchenko@solarflare.com>2019-11-19 08:22:50 +0000
committerFerruh Yigit <ferruh.yigit@intel.com>2019-11-20 17:36:06 +0100
commit6e18704b7e19855a0744cf4b291f1d1fe874d710 (patch)
tree6a10eb7e4baacd8a6f085042d5d7e6a610f69870
parent3b4888d53d6b1dc719d1afe8fac7efebebcf0925 (diff)
downloaddpdk-next-net-intel-6e18704b7e19855a0744cf4b291f1d1fe874d710.zip
dpdk-next-net-intel-6e18704b7e19855a0744cf4b291f1d1fe874d710.tar.gz
dpdk-next-net-intel-6e18704b7e19855a0744cf4b291f1d1fe874d710.tar.xz
ethdev: avoid undefined behaviour on configuration copy
memcpy() source and destination areas must not overlap and equal pointers is the case which is really met, so handle it. Fixes: 68b931bff287 ("ethdev: eliminate interim variable") Cc: stable@dpdk.org Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
-rw-r--r--lib/librte_ethdev/rte_ethdev.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 8f48e8d..8d2ce31 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -1245,7 +1245,9 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
* Copy the dev_conf parameter into the dev structure.
* rte_eth_dev_info_get() requires dev_conf, copy it before dev_info get
*/
- memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
+ if (dev_conf != &dev->data->dev_conf)
+ memcpy(&dev->data->dev_conf, dev_conf,
+ sizeof(dev->data->dev_conf));
ret = rte_eth_dev_info_get(port_id, &dev_info);
if (ret != 0)