nvethernet: fix coverity defects

CID 9871576 Untrusted array index read
CID 10112340 Dereference before null check
CID 10127838 Unchecked return value
CID 10127841 Dead default in switch
CID 10127905 Unchecked return value
CID 10127961 Unused value

Bug 3461002

Change-Id: If041434e57295b282dacf06ed66b1a436b96a165
Signed-off-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2665776
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Mohan Thadikamalla <mohant@nvidia.com>
Reviewed-by: Rakesh Goyal <rgoyal@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Bhadram Varka
2022-02-08 18:16:06 +05:30
committed by Revanth Kumar Uppala
parent 0bc5754577
commit ad01764abb
6 changed files with 28 additions and 14 deletions

View File

@@ -4996,15 +4996,15 @@ static int ether_get_eqos_clks(struct ether_priv_data *pdata)
goto err_tx;
}
/* This is optional clk */
pdata->rx_m_clk = devm_clk_get(dev, "eqos_rx_m");
if (IS_ERR(pdata->rx_m_clk)) {
ret = PTR_ERR(pdata->rx_m_clk);
dev_info(dev, "failed to get eqos_rx_m clk\n");
}
/* This is optional clk */
pdata->rx_input_clk = devm_clk_get(dev, "eqos_rx_input");
if (IS_ERR(pdata->rx_input_clk)) {
ret = PTR_ERR(pdata->rx_input_clk);
dev_info(dev, "failed to get eqos_rx_input clk\n");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -1396,9 +1396,6 @@ static void ether_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
{
struct ether_priv_data *pdata = netdev_priv(ndev);
wol->supported = 0;
wol->wolopts = 0;
if (!wol)
return;
@@ -1409,6 +1406,9 @@ static void ether_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
return;
}
wol->supported = 0;
wol->wolopts = 0;
if (!phy_interrupt_is_valid(pdata->phydev))
return;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -141,6 +141,11 @@ static int ether_set_avb_algo(struct net_device *ndev,
return ret;
}
if (ioctl_data.avb.qindex >= OSI_MGBE_MAX_NUM_QUEUES) {
dev_err(pdata->dev, "Invalid queue index from user\n");
return -EINVAL;
}
/* Check AVB mode disable on slot function enable */
tx_ring = osi_dma->tx_ring[ioctl_data.avb.qindex];
if (tx_ring && tx_ring->slot_check == OSI_ENABLE &&

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -922,7 +922,12 @@ int osd_ivc_send_cmd(void *priv, ivc_msg_common_t *ivc_buf, unsigned int len)
dcnt = IVC_READ_TIMEOUT_CNT;
while ((!tegra_hv_ivc_can_read(ictxt->ivck))) {
wait_for_completion_timeout(&ictxt->msg_complete, IVC_WAIT_TIMEOUT);
if (!wait_for_completion_timeout(&ictxt->msg_complete,
IVC_WAIT_TIMEOUT)) {
ret = -ETIMEDOUT;
goto fail;
}
dcnt--;
if (!dcnt) {
dev_err(pdata->dev, "IVC read timeout\n");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -249,7 +249,12 @@ static int ether_test_loopback(struct ether_priv_data *pdata,
if (ret)
goto cleanup;
wait_for_completion_timeout(&tpdata->comp, msecs_to_jiffies(200));
if (!wait_for_completion_timeout(&tpdata->comp,
msecs_to_jiffies(200))) {
ret = -ETIMEDOUT;
goto cleanup;
}
ret = !tpdata->completed;
cleanup:
dev_remove_pack(&tpdata->pt);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -684,11 +684,10 @@ static int parse_inputs(const char *buf,
case 2:
flags |= OSI_LUT_FLAGS_BYTE2_PATTERN_VALID;
break;
default:
case 3:
flags |= OSI_LUT_FLAGS_BYTE3_PATTERN_VALID;
break;
default:
break;
}
lut_in->byte_pattern[i] = byte[i];
lut_in->byte_pattern_offset[i] = byte_offset[i];