Skip to content

Commit

Permalink
netdev-dpdk: Fix possible memory leak configuring VF MAC address.
Browse files Browse the repository at this point in the history
VLOG_WARN_BUF() is allocating memory for the error string and should
e used if the configuration cannot continue and error is being returned
so the caller has indication of releasing the pointer.
Change to VLOG_WARN() to keep the logic that error is not being
returned.

Fixes: f4336f5 ("netdev-dpdk: Add option to configure VF MAC address.")
Signed-off-by: Roi Dayan <roid@nvidia.com>
Acked-by: Gaetan Rivet <gaetanr@nvidia.com>
Acked-by: Eli Britstein <elibr@nvidia.com>
Signed-off-by: Simon Horman <horms@ovn.org>
  • Loading branch information
Roi Dayan via dev authored and Simon Horman committed Apr 23, 2024
1 parent d4d309b commit 5353563
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/netdev-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2015,17 +2015,16 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args,
struct eth_addr mac;

if (!dpdk_port_is_representor(dev)) {
VLOG_WARN_BUF(errp, "'%s' is trying to set the VF MAC '%s' "
"but 'options:dpdk-vf-mac' is only supported for "
"VF representors.",
netdev_get_name(netdev), vf_mac);
VLOG_WARN("'%s' is trying to set the VF MAC '%s' "
"but 'options:dpdk-vf-mac' is only supported for "
"VF representors.",
netdev_get_name(netdev), vf_mac);
} else if (!eth_addr_from_string(vf_mac, &mac)) {
VLOG_WARN_BUF(errp, "interface '%s': cannot parse VF MAC '%s'.",
netdev_get_name(netdev), vf_mac);
VLOG_WARN("interface '%s': cannot parse VF MAC '%s'.",
netdev_get_name(netdev), vf_mac);
} else if (eth_addr_is_multicast(mac)) {
VLOG_WARN_BUF(errp,
"interface '%s': cannot set VF MAC to multicast "
"address '%s'.", netdev_get_name(netdev), vf_mac);
VLOG_WARN("interface '%s': cannot set VF MAC to multicast "
"address '%s'.", netdev_get_name(netdev), vf_mac);
} else if (!eth_addr_equals(dev->requested_hwaddr, mac)) {
dev->requested_hwaddr = mac;
netdev_request_reconfigure(netdev);
Expand Down

0 comments on commit 5353563

Please sign in to comment.