summaryrefslogtreecommitdiff
path: root/lib/netdev-dpdk.c
diff options
context:
space:
mode:
authorAaron Conole <aconole@redhat.com>2020-01-09 13:27:06 -0500
committerIan Stokes <ian.stokes@intel.com>2020-01-13 16:35:21 +0000
commitcefdd80a29eb2690fd62eea3e5c61cec61b2f195 (patch)
tree5b36da5f262fb8be66abbd2c9e15fdaa1ffb97c6 /lib/netdev-dpdk.c
parent2109841b798451230255c34d6724e17a6f075aa5 (diff)
downloadopenvswitch-cefdd80a29eb2690fd62eea3e5c61cec61b2f195.tar.gz
netdev-dpdk: Avoid undefined behavior processing devargs
In "Use of library functions" in the C standard, the following statement is written to apply to all library functions: If an argument to a function has an invalid value (such as ... a null pointer ... the behavior is undefined. Later, under the "String handling" section, "Comparison functions" no exception is listed for strcmp, which means NULL is invalid. It may be possible for the smap_get to return NULL. Given the above, we must check that new_devargs is not null. The check against NULL for new_devargs later in the function is still valid. Fixes: 55e075e65ef9 ("netdev-dpdk: Arbitrary 'dpdk' port naming") Signed-off-by: Aaron Conole <aconole@redhat.com> Acked-by: Ciara Loftus <ciara.loftus@intel.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Diffstat (limited to 'lib/netdev-dpdk.c')
-rw-r--r--lib/netdev-dpdk.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 8198a0b7d..f439fad26 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1855,7 +1855,7 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args,
new_devargs = smap_get(args, "dpdk-devargs");
- if (dev->devargs && strcmp(new_devargs, dev->devargs)) {
+ if (dev->devargs && new_devargs && strcmp(new_devargs, dev->devargs)) {
/* The user requested a new device. If we return error, the caller
* will delete this netdev and try to recreate it. */
err = EAGAIN;