mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 17:25:35 +03:00
nvethernet: handling new CERT errors
CERT INT08-C CERT STR07-C Jira NET-2907 Change-Id: If331caf9838840073792de5ac722f268920c4a87 Signed-off-by: Sanath Kumar Gampa <sgampa@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3328902 Reviewed-by: Bhadram Varka <vbhadram@nvidia.com> Reviewed-by: Srinivas Ramachandran <srinivasra@nvidia.com> GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Jon Hunter
parent
d3cdce84ec
commit
5a5cf6254f
@@ -3600,8 +3600,8 @@ static int ether_handle_tso(struct device *dev,
|
||||
tx_pkt_cx->mss = skb_shinfo(skb)->gso_size;
|
||||
}
|
||||
|
||||
if (((UINT_MAX - transport_offset) < tx_pkt_cx->tcp_udp_hdrlen) ||
|
||||
((transport_offset + tx_pkt_cx->tcp_udp_hdrlen) > (unsigned int)skb->len)) {
|
||||
if (unlikely(((UINT_MAX - transport_offset) < tx_pkt_cx->tcp_udp_hdrlen) ||
|
||||
((transport_offset + tx_pkt_cx->tcp_udp_hdrlen) > (unsigned int)skb->len))) {
|
||||
dev_err(dev, "Invalid header length calculations\n");
|
||||
ret = -EINVAL;
|
||||
goto func_exit;
|
||||
@@ -3642,11 +3642,15 @@ static void ether_tx_swcx_rollback(struct ether_priv_data *pdata,
|
||||
struct osi_tx_swcx *tx_swcx = NULL;
|
||||
|
||||
while (count > 0) {
|
||||
if ((pdata->osi_dma->tx_ring_sz == 0U) || (cur_tx_idx == 0U)) {
|
||||
if (unlikely(pdata->osi_dma->tx_ring_sz == 0U)) {
|
||||
dev_err(dev, "Invalid Tx ring size or index\n");
|
||||
break;
|
||||
}
|
||||
if (cur_tx_idx != 0U) {
|
||||
DECR_TX_DESC_INDEX(cur_tx_idx, pdata->osi_dma->tx_ring_sz);
|
||||
} else {
|
||||
cur_tx_idx = pdata->osi_dma->tx_ring_sz - 1U;
|
||||
}
|
||||
tx_swcx = tx_ring->tx_swcx + cur_tx_idx;
|
||||
if (tx_swcx->buf_phy_addr) {
|
||||
if ((tx_swcx->flags & OSI_PKT_CX_PAGED_BUF) ==
|
||||
@@ -3728,7 +3732,7 @@ static int ether_tx_swcx_alloc(struct ether_priv_data *pdata,
|
||||
tx_pkt_cx->flags |= OSI_PKT_CX_PTP;
|
||||
}
|
||||
|
||||
if (pdata->osi_dma->tx_ring_sz == 0U) {
|
||||
if (unlikely(pdata->osi_dma->tx_ring_sz == 0U)) {
|
||||
dev_err(dev, "Invalid Tx ring size\n");
|
||||
goto exit_func;
|
||||
}
|
||||
@@ -3783,7 +3787,7 @@ static int ether_tx_swcx_alloc(struct ether_priv_data *pdata,
|
||||
tx_swcx->len = size;
|
||||
len -= size;
|
||||
offset += size;
|
||||
if (cnt == (int)INT_MAX) {
|
||||
if (unlikely(cnt == (int)INT_MAX)) {
|
||||
dev_err(dev, "Reached Max desc count\n");
|
||||
ret = -ENOMEM;
|
||||
goto dma_map_failed;
|
||||
@@ -3827,7 +3831,7 @@ static int ether_tx_swcx_alloc(struct ether_priv_data *pdata,
|
||||
goto dma_map_failed;
|
||||
}
|
||||
offset += size;
|
||||
if (cnt == (int)INT_MAX) {
|
||||
if (unlikely(cnt == (int)INT_MAX)) {
|
||||
dev_err(dev, "Reached Max desc count\n");
|
||||
ret = -ENOMEM;
|
||||
goto dma_map_failed;
|
||||
@@ -3850,7 +3854,7 @@ static int ether_tx_swcx_alloc(struct ether_priv_data *pdata,
|
||||
}
|
||||
|
||||
size = min(len, max_data_len_per_txd);
|
||||
if (skb_frag_off(frag) > UINT_MAX - offset) {
|
||||
if (unlikely(skb_frag_off(frag) > UINT_MAX - offset)) {
|
||||
dev_err(dev, "Offset addition overflow detected:"
|
||||
"frag offset = %u, offset = %u\n",
|
||||
skb_frag_off(frag), offset);
|
||||
@@ -3873,7 +3877,7 @@ static int ether_tx_swcx_alloc(struct ether_priv_data *pdata,
|
||||
tx_swcx->len = size;
|
||||
len -= size;
|
||||
offset += size;
|
||||
if (cnt == (int)INT_MAX) {
|
||||
if (unlikely(cnt == (int)INT_MAX)) {
|
||||
dev_err(dev, "Reached Max desc count\n");
|
||||
ret = -ENOMEM;
|
||||
goto dma_map_failed;
|
||||
@@ -7908,7 +7912,9 @@ int ether_suspend_noirq(struct device *dev)
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
t1 = ether_get_systime_us();
|
||||
if (t1 >= t0) {
|
||||
pdata->suspend_profile_time = (t1 - t0);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -7943,7 +7949,9 @@ int ether_resume_noirq(struct device *dev)
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
t1 = ether_get_systime_us();
|
||||
if (t1 >= t0) {
|
||||
pdata->resume_profile_time = (t1 - t0);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -338,14 +338,19 @@ static inline bool valid_tx_len(unsigned int length)
|
||||
static inline int ether_avail_txdesc_cnt(struct osi_dma_priv_data *osi_dma,
|
||||
struct osi_tx_ring *tx_ring)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
|
||||
if ((osi_dma->tx_ring_sz == 0U) || (tx_ring->cur_tx_idx == 0U) ||
|
||||
(tx_ring->clean_idx < (tx_ring->cur_tx_idx - 1U))) {
|
||||
return ret;
|
||||
if (unlikely((osi_dma->tx_ring_sz == 0U) ||
|
||||
(tx_ring->cur_tx_idx >= osi_dma->tx_ring_sz))) {
|
||||
return -EINVAL;
|
||||
}
|
||||
return ((tx_ring->clean_idx - tx_ring->cur_tx_idx - 1U) &
|
||||
|
||||
if (tx_ring->clean_idx > (tx_ring->cur_tx_idx + 1U)) {
|
||||
return ((tx_ring->clean_idx - (tx_ring->cur_tx_idx + 1U)) &
|
||||
(osi_dma->tx_ring_sz - 1U));
|
||||
} else {
|
||||
return (((tx_ring->clean_idx + osi_dma->tx_ring_sz) -
|
||||
(tx_ring->cur_tx_idx + 1U)) &
|
||||
(osi_dma->tx_ring_sz - 1U));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1471,10 +1471,8 @@ int macsec_probe(struct ether_priv_data *pdata)
|
||||
ret = -1;
|
||||
goto genl_err;
|
||||
} else {
|
||||
strncpy(macsec_pdata->nv_macsec_fam.name,
|
||||
netdev_name(pdata->ndev), GENL_NAMSIZ - 1);
|
||||
// Explicit null-termination to fix CERT STR07-C
|
||||
macsec_pdata->nv_macsec_fam.name[GENL_NAMSIZ - 1] = '\0';
|
||||
snprintf(macsec_pdata->nv_macsec_fam.name, GENL_NAMSIZ,
|
||||
netdev_name(pdata->ndev));
|
||||
}
|
||||
ret = genl_register_family(&macsec_pdata->nv_macsec_fam);
|
||||
if (ret) {
|
||||
|
||||
Reference in New Issue
Block a user