eal: fix possible crash in hotplug
If devargs is NULL, building the full_dev_name will segfault
when using strlen on it.
Coverity issue: 158630
Fixes: 7e8b266501
("eal: fix hotplug add / remove")
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
This commit is contained in:
parent
b631f3b0f2
commit
3054036f05
@ -133,16 +133,13 @@ full_dev_name(const char *bus, const char *dev, const char *args)
|
||||
char *name;
|
||||
size_t len;
|
||||
|
||||
len = strlen(bus) + 1 +
|
||||
strlen(dev) + 1 +
|
||||
strlen(args) + 1;
|
||||
len = snprintf(NULL, 0, "%s:%s,%s", bus, dev, args);
|
||||
name = calloc(1, len);
|
||||
if (name == NULL) {
|
||||
RTE_LOG(ERR, EAL, "Could not allocate full device name\n");
|
||||
return NULL;
|
||||
}
|
||||
snprintf(name, len, "%s:%s,%s", bus, dev,
|
||||
args ? args : "");
|
||||
snprintf(name, len, "%s:%s,%s", bus, dev, args);
|
||||
return name;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user