vhost: check for strdup failure
We could silently fail the allocation and probably segfault soon after. Change-Id: I3851b78500fcb3f64a06bdf0c0e5566d6148cbee Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447026 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
55656fb19f
commit
49e0400920
@ -753,6 +753,14 @@ spdk_vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const cha
|
|||||||
|
|
||||||
vdev->name = strdup(name);
|
vdev->name = strdup(name);
|
||||||
vdev->path = strdup(path);
|
vdev->path = strdup(path);
|
||||||
|
if (vdev->name == NULL || vdev->path == NULL) {
|
||||||
|
free(vdev->name);
|
||||||
|
free(vdev->path);
|
||||||
|
rte_vhost_driver_unregister(path);
|
||||||
|
rc = -EIO;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
vdev->cpumask = cpumask;
|
vdev->cpumask = cpumask;
|
||||||
vdev->registered = true;
|
vdev->registered = true;
|
||||||
vdev->backend = backend;
|
vdev->backend = backend;
|
||||||
|
Loading…
Reference in New Issue
Block a user