pci: fix potential mem leaks
Looking at bsd implementation, we can see that there are some potential mem leaks in linux implementation. Fix them. Signed-off-by: David Marchand <david.marchand@6wind.com> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com> Acked-by: Neil Horman <nhorman@tuxdriver.com>
This commit is contained in:
parent
0c3977dd15
commit
8990aac31d
@ -649,11 +649,13 @@ pci_uio_map_resource(struct rte_pci_device *dev)
|
|||||||
memcpy(&uio_res->pci_addr, &dev->addr, sizeof(uio_res->pci_addr));
|
memcpy(&uio_res->pci_addr, &dev->addr, sizeof(uio_res->pci_addr));
|
||||||
|
|
||||||
/* collect info about device mappings */
|
/* collect info about device mappings */
|
||||||
if ((nb_maps = pci_uio_get_mappings(dirname, uio_res->maps,
|
nb_maps = pci_uio_get_mappings(dirname, uio_res->maps,
|
||||||
sizeof (uio_res->maps) / sizeof (uio_res->maps[0])))
|
RTE_DIM(uio_res->maps));
|
||||||
< 0)
|
if (nb_maps < 0) {
|
||||||
|
rte_free(uio_res);
|
||||||
return (nb_maps);
|
return (nb_maps);
|
||||||
|
}
|
||||||
|
|
||||||
uio_res->nb_maps = nb_maps;
|
uio_res->nb_maps = nb_maps;
|
||||||
|
|
||||||
/* Map all BARs */
|
/* Map all BARs */
|
||||||
@ -678,6 +680,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)
|
|||||||
(mapaddr = pci_map_resource(dev,
|
(mapaddr = pci_map_resource(dev,
|
||||||
NULL, devname, (off_t)offset,
|
NULL, devname, (off_t)offset,
|
||||||
(size_t)maps[j].size)) == NULL) {
|
(size_t)maps[j].size)) == NULL) {
|
||||||
|
rte_free(uio_res);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user