Check return values of ioctl() calls for NBL_DEV_USER_GET_BAR_SIZE
and NBL_DEV_USER_CLEAR_EVENTFD. The original code tested the return
value without capturing it from the ioctl call.
Coverity issue: 490947
Coverity issue: 490951
Fixes: dc955cd24c8f ("net/nbl: add coexistence mode")
Cc: [email protected]
Signed-off-by: Dimon Zhao <[email protected]>
---
drivers/net/nbl/nbl_common/nbl_userdev.c | 25 ++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/drivers/net/nbl/nbl_common/nbl_userdev.c
b/drivers/net/nbl/nbl_common/nbl_userdev.c
index 566f3a11ee..96f0d2e264 100644
--- a/drivers/net/nbl/nbl_common/nbl_userdev.c
+++ b/drivers/net/nbl/nbl_common/nbl_userdev.c
@@ -724,17 +724,19 @@ int nbl_pci_map_device(struct nbl_adapter *adapter)
}
common->eventfd = fd;
- ioctl(common->devfd, NBL_DEV_USER_GET_BAR_SIZE, &bar_size);
+ ret = ioctl(common->devfd, NBL_DEV_USER_GET_BAR_SIZE, &bar_size);
+ if (ret) {
+ NBL_LOG(ERR, "nbl userdev get bar size failed");
+ goto close_eventfd;
+ }
- if (!ret) {
- pci_dev->mem_resource[0].addr = nbl_userdev_mmap(common->devfd,
0, bar_size);
- pci_dev->mem_resource[0].phys_addr = 0;
- pci_dev->mem_resource[0].len = bar_size;
- pci_dev->mem_resource[2].addr = 0;
+ pci_dev->mem_resource[0].addr = nbl_userdev_mmap(common->devfd, 0,
bar_size);
+ pci_dev->mem_resource[0].phys_addr = 0;
+ pci_dev->mem_resource[0].len = bar_size;
+ pci_dev->mem_resource[2].addr = 0;
- common->ifindex = nbl_userdev_get_ifindex(common->devfd);
- common->nl_socket_route = nbl_userdev_nl_init(NETLINK_ROUTE);
- }
+ common->ifindex = nbl_userdev_get_ifindex(common->devfd);
+ common->nl_socket_route = nbl_userdev_nl_init(NETLINK_ROUTE);
return ret;
@@ -753,12 +755,15 @@ void nbl_pci_unmap_device(struct nbl_adapter *adapter)
{
struct rte_pci_device *pci_dev = adapter->pci_dev;
struct nbl_common_info *common = &adapter->common;
+ int ret;
if (NBL_IS_NOT_COEXISTENCE(common))
return rte_pci_unmap_device(pci_dev);
rte_mem_unmap(pci_dev->mem_resource[0].addr,
pci_dev->mem_resource[0].len);
- ioctl(common->devfd, NBL_DEV_USER_CLEAR_EVENTFD, 0);
+ ret = ioctl(common->devfd, NBL_DEV_USER_CLEAR_EVENTFD, 0);
+ if (ret)
+ NBL_LOG(ERR, "nbl userdev set clear eventfd failed, ret: %d",
ret);
close(common->eventfd);
close(common->nl_socket_route);
--
2.34.1