Skip to content

Commit f417655

Browse files
Dimon-Zhaoshemminger
authored andcommitted
net/nbl: fix issues reported by Coverity
Coverity issue: 490942 Coverity issue: 490943 Coverity issue: 490946 Coverity issue: 490947 Coverity issue: 490949 Coverity issue: 490950 Coverity issue: 490951 Coverity issue: 490952 Coverity issue: 490953 Coverity issue: 490954 Coverity issue: 490955 Coverity issue: 490957 Coverity issue: 490958 Coverity issue: 490959 Fixes: a1c5ffa ("net/nbl: add channel layer") Fixes: dc955cd ("net/nbl: add coexistence mode") Fixes: 93b38df ("net/nbl: support basic configuration") Signed-off-by: Dimon Zhao <[email protected]>
1 parent cb699a0 commit f417655

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

drivers/net/nbl/nbl_common/nbl_userdev.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,11 @@ int nbl_pci_map_device(struct nbl_adapter *adapter)
715715
}
716716

717717
common->eventfd = fd;
718-
ioctl(common->devfd, NBL_DEV_USER_GET_BAR_SIZE, &bar_size);
718+
ret = ioctl(common->devfd, NBL_DEV_USER_GET_BAR_SIZE, &bar_size);
719+
if (ret) {
720+
NBL_LOG(ERR, "nbl userdev get bar size failed");
721+
goto close_eventfd;
722+
}
719723

720724
if (!ret) {
721725
pci_dev->mem_resource[0].addr = nbl_userdev_mmap(common->devfd, 0, bar_size);
@@ -744,12 +748,15 @@ void nbl_pci_unmap_device(struct nbl_adapter *adapter)
744748
{
745749
struct rte_pci_device *pci_dev = adapter->pci_dev;
746750
struct nbl_common_info *common = &adapter->common;
751+
int ret = 0;
747752

748753
if (NBL_IS_NOT_COEXISTENCE(common))
749754
return rte_pci_unmap_device(pci_dev);
750755

751756
rte_mem_unmap(pci_dev->mem_resource[0].addr, pci_dev->mem_resource[0].len);
752-
ioctl(common->devfd, NBL_DEV_USER_CLEAR_EVENTFD, 0);
757+
ret = ioctl(common->devfd, NBL_DEV_USER_CLEAR_EVENTFD, 0);
758+
if (ret)
759+
NBL_LOG(ERR, "nbl userdev set clear eventfd failed, ret: %d", ret);
753760
close(common->eventfd);
754761
close(common->nl_socket_route);
755762

drivers/net/nbl/nbl_dev/nbl_dev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ int nbl_dev_configure(struct rte_eth_dev *eth_dev)
1818
struct nbl_adapter *adapter = ETH_DEV_TO_NBL_DEV_PF_PRIV(eth_dev);
1919
int ret;
2020

21-
NBL_LOG(DEBUG, "Begin to configure the device, state: %d", adapter->state);
22-
2321
if (dev_data == NULL || adapter == NULL)
2422
return -EINVAL;
2523

24+
NBL_LOG(DEBUG, "Begin to configure the device, state: %d", adapter->state);
25+
2626
if (rx_mq_mode != RTE_ETH_MQ_RX_NONE && rx_mq_mode != RTE_ETH_MQ_RX_RSS) {
2727
NBL_LOG(ERR, "Rx mq mode %d is not supported", rx_mq_mode);
2828
return -ENOTSUP;

drivers/net/nbl/nbl_hw/nbl_channel.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static int nbl_chan_init_tx_queue(union nbl_chan_info *chan_info)
3636
goto req_wait_queue_failed;
3737
}
3838

39-
size = chan_info->mailbox.num_txq_entries * chan_info->mailbox.txq_buf_size;
39+
size = (u64)chan_info->mailbox.num_txq_entries * (u64)chan_info->mailbox.txq_buf_size;
4040
txq->buf = nbl_alloc_dma_mem(&txq->buf_mem, size);
4141
if (!txq->buf) {
4242
NBL_LOG(ERR, "Allocate memory for chan tx buffer arrays failed");
@@ -66,7 +66,7 @@ static int nbl_chan_init_rx_queue(union nbl_chan_info *chan_info)
6666
return -ENOMEM;
6767
}
6868

69-
size = chan_info->mailbox.num_rxq_entries * chan_info->mailbox.rxq_buf_size;
69+
size = (u64)chan_info->mailbox.num_rxq_entries * (u64)chan_info->mailbox.rxq_buf_size;
7070
rxq->buf = nbl_alloc_dma_mem(&rxq->buf_mem, size);
7171
if (!rxq->buf) {
7272
NBL_LOG(ERR, "Allocate memory for chan rx buffer arrays failed");
@@ -163,7 +163,7 @@ static int nbl_chan_prepare_rx_bufs(struct nbl_channel_mgt *chan_mgt,
163163
desc = rxq->desc;
164164
for (i = 0; i < chan_info->mailbox.num_rxq_entries - 1; i++) {
165165
desc[i].flags = NBL_CHAN_RX_DESC_AVAIL;
166-
desc[i].buf_addr = rxq->buf_mem.pa + i * chan_info->mailbox.rxq_buf_size;
166+
desc[i].buf_addr = rxq->buf_mem.pa + (u64)i * (u64)chan_info->mailbox.rxq_buf_size;
167167
desc[i].buf_len = chan_info->mailbox.rxq_buf_size;
168168
}
169169

@@ -324,7 +324,8 @@ static void nbl_chan_advance_rx_ring(struct nbl_channel_mgt *chan_mgt,
324324
rx_desc = NBL_CHAN_RX_DESC(rxq, next_to_use);
325325

326326
rx_desc->flags = NBL_CHAN_RX_DESC_AVAIL;
327-
rx_desc->buf_addr = rxq->buf_mem.pa + chan_info->mailbox.rxq_buf_size * next_to_use;
327+
rx_desc->buf_addr = rxq->buf_mem.pa +
328+
(u64)chan_info->mailbox.rxq_buf_size * (u64)next_to_use;
328329
rx_desc->buf_len = chan_info->mailbox.rxq_buf_size;
329330

330331
rte_wmb();
@@ -376,8 +377,8 @@ static uint16_t nbl_chan_update_txqueue(union nbl_chan_info *chan_info,
376377

377378
txq = &chan_info->mailbox.txq;
378379
next_to_use = txq->next_to_use;
379-
va = (u8 *)txq->buf + next_to_use * chan_info->mailbox.txq_buf_size;
380-
pa = txq->buf_mem.pa + next_to_use * chan_info->mailbox.txq_buf_size;
380+
va = (u8 *)txq->buf + (u64)next_to_use * (u64)chan_info->mailbox.txq_buf_size;
381+
pa = txq->buf_mem.pa + (u64)next_to_use * (u64)chan_info->mailbox.txq_buf_size;
381382
tx_desc = NBL_CHAN_TX_DESC(txq, next_to_use);
382383

383384
tx_desc->dstid = dstid;

0 commit comments

Comments
 (0)