pci: fix memory leaks and needless increment of map address
authorTetsuya Mukawa <mukawa@igel.co.jp>
Wed, 8 Jul 2015 10:34:44 +0000 (19:34 +0900)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 8 Jul 2015 21:50:22 +0000 (23:50 +0200)
commit1acc43383cf66fb4dcc7633c918d0064290c1031
tree1ea2b8ff164a7cbdc608ab19d7f897ea7691a851
parentd428dab038318f0f07939eae94744ee43a47591a
pci: fix memory leaks and needless increment of map address

This patch fixes following memory leaks.
- When open() is failed, uio_res and fds won't be freed in
  pci_uio_map_resource().
- When pci_map_resource() is failed but path is allocated correctly,
  path and fds won't be freed in pci_uio_map_recource().
  Also, some mapped resources should be freed.
- When pci_uio_unmap() is called, path should be freed.

Also, fixes below.
- When pci_map_resource() is failed, mapaddr will be MAP_FAILED.
  In this case, pci_map_addr should not be incremented in
  pci_uio_map_resource().
- To shrink code, move close().
- Remove fail variable.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
lib/librte_eal/bsdapp/eal/eal_pci.c
lib/librte_eal/linuxapp/eal/eal_pci_uio.c