Skip to content

Commit

Permalink
netdev-dpdk: Avoid undefined behavior processing devargs
Browse files Browse the repository at this point in the history
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: 55e075e ("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>
  • Loading branch information
apconole authored and istokes committed Jan 13, 2020
1 parent 6c76640 commit f2c9156
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/netdev-dpdk.c
Expand Up @@ -1570,7 +1570,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;
Expand Down

0 comments on commit f2c9156

Please sign in to comment.