Skip to content

Commit dd3cc52

Browse files
Mikhail Dmitrichenkokevintraynor
authored andcommitted
netdev-dpdk: Fix memory leak when configuring rx-steering.
VLOG_WARN_BUF() allocates a new string with xasprintf() every time it is called and overwrites *errp without freeing the previous value. This can lead to a memory leak if multiple warnings are emitted or if a later hard error in netdev_dpdk_set_config() also writes to errp. The three cases in dpdk_set_rx_steer_config() are not fatal errors: - unsupported rx-steering value - rss+lacp on non-ethernet port - rss+lacp together with hw-offload In all cases program simply log a warning and fall back to default RSS steering. Configuration continues normally (err remains 0 and execution flow do not goto out). Therefore change them to plain VLOG_WARN(). As a result the 'errp' parameter becomes unused and is removed from the function signature and the call site in netdev_dpdk_set_config(). This makes the code cleaner and consistent with the rest of netdev-dpdk. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: fc06ea9 ("netdev-dpdk: Add custom rx-steering configuration.") Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com> Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
1 parent 097f472 commit dd3cc52

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

lib/netdev-dpdk.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,30 +2270,28 @@ dpdk_process_queue_size(struct netdev *netdev, const struct smap *args,
22702270

22712271
static void
22722272
dpdk_set_rx_steer_config(struct netdev *netdev, struct netdev_dpdk *dev,
2273-
const struct smap *args, char **errp)
2273+
const struct smap *args)
22742274
{
22752275
const char *arg = smap_get_def(args, "rx-steering", "rss");
22762276
uint64_t flags = 0;
22772277

22782278
if (!strcmp(arg, "rss+lacp")) {
22792279
flags = DPDK_RX_STEER_LACP;
22802280
} else if (strcmp(arg, "rss")) {
2281-
VLOG_WARN_BUF(errp, "%s: options:rx-steering "
2282-
"unsupported parameter value '%s'",
2283-
netdev_get_name(netdev), arg);
2281+
VLOG_WARN("%s: options:rx-steering unsupported parameter value '%s'",
2282+
netdev_get_name(netdev), arg);
22842283
}
22852284

22862285
if (flags && dev->type != DPDK_DEV_ETH) {
2287-
VLOG_WARN_BUF(errp, "%s: options:rx-steering "
2288-
"is only supported on ethernet ports",
2289-
netdev_get_name(netdev));
2286+
VLOG_WARN("%s: options:rx-steering "
2287+
"is only supported on ethernet ports",
2288+
netdev_get_name(netdev));
22902289
flags = 0;
22912290
}
22922291

22932292
if (flags && netdev_is_flow_api_enabled()) {
2294-
VLOG_WARN_BUF(errp, "%s: options:rx-steering "
2295-
"is incompatible with hw-offload",
2296-
netdev_get_name(netdev));
2293+
VLOG_WARN("%s: options:rx-steering is incompatible with hw-offload",
2294+
netdev_get_name(netdev));
22972295
flags = 0;
22982296
}
22992297

@@ -2323,7 +2321,7 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args,
23232321
ovs_mutex_lock(&dpdk_mutex);
23242322
ovs_mutex_lock(&dev->mutex);
23252323

2326-
dpdk_set_rx_steer_config(netdev, dev, args, errp);
2324+
dpdk_set_rx_steer_config(netdev, dev, args);
23272325

23282326
dpdk_set_rxq_config(dev, args);
23292327

0 commit comments

Comments
 (0)