Skip to content

Commit

Permalink
ethdev: avoid undefined behaviour on configuration copy
Browse files Browse the repository at this point in the history
[ upstream commit 6e18704 ]

memcpy() source and destination areas must not overlap and equal
pointers is the case which is really met, so handle it.

Fixes: 68b931b ("ethdev: eliminate interim variable")

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
arybchenko authored and kevintraynor committed Dec 11, 2019
1 parent f64b314 commit b451f20
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/librte_ethdev/rte_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,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));

rte_eth_dev_info_get(port_id, &dev_info);

Expand Down

0 comments on commit b451f20

Please sign in to comment.