X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=lib%2Flibrte_vhost%2Fvdpa.c;fp=lib%2Flibrte_vhost%2Fvdpa.c;h=f560419b13cf0c4a310912390bf8f001b15ea2a6;hb=8d53e9f3c6001dcb2865f6e894da5b54e1418f88;hp=e7d849ee0f4f1f91661cdf0dcebbbb7365e3b4ba;hpb=e2bea7436061ca2e7e14bfcfdc5870f2555c3965;p=deb_dpdk.git diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c index e7d849ee..f560419b 100644 --- a/lib/librte_vhost/vdpa.c +++ b/lib/librte_vhost/vdpa.c @@ -49,7 +49,7 @@ rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr, char device_name[MAX_VDPA_NAME_LEN]; int i; - if (vdpa_device_num >= MAX_VHOST_DEVICE) + if (vdpa_device_num >= MAX_VHOST_DEVICE || addr == NULL || ops == NULL) return -1; for (i = 0; i < MAX_VHOST_DEVICE; i++) { @@ -66,7 +66,7 @@ rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr, if (i == MAX_VHOST_DEVICE) return -1; - sprintf(device_name, "vdpa-dev-%d", i); + snprintf(device_name, sizeof(device_name), "vdpa-dev-%d", i); dev = rte_zmalloc(device_name, sizeof(struct rte_vdpa_device), RTE_CACHE_LINE_SIZE); if (!dev) @@ -99,6 +99,9 @@ rte_vdpa_find_device_id(struct rte_vdpa_dev_addr *addr) struct rte_vdpa_device *dev; int i; + if (addr == NULL) + return -1; + for (i = 0; i < MAX_VHOST_DEVICE; ++i) { dev = vdpa_devices[i]; if (dev && is_same_vdpa_device(&dev->addr, addr))