PCI: edma_test: Fix Coverity issues

Validate num_chans before using for division

Bug 3956683

Signed-off-by: Nagarjuna Kristam <nkristam@nvidia.com>
Change-Id: I8abca2a251748711f07ffc14d71b1601fa73806f
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2876298
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Nagarjuna Kristam
2023-03-24 11:55:46 +05:30
committed by mobile promotions
parent ff5e03daaf
commit b3bfce4122

View File

@@ -2,7 +2,7 @@
/* /*
* PCIe DMA EPF Library for Tegra PCIe * PCIe DMA EPF Library for Tegra PCIe
* *
* Copyright (C) 2022 NVIDIA Corporation. All rights reserved. * Copyright (C) 2022-2023 NVIDIA Corporation. All rights reserved.
*/ */
#ifndef TEGRA_PCIE_EDMA_TEST_COMMON_H #ifndef TEGRA_PCIE_EDMA_TEST_COMMON_H
@@ -196,7 +196,9 @@ static int edmalib_common_test(struct edmalib_common *edma)
return 0; return 0;
} }
nents_per_ch = nents / num_chans; if (num_chans != 0)
nents_per_ch = nents / num_chans;
if (nents_per_ch == 0) { if (nents_per_ch == 0) {
dev_err(edma->fdev, "%s: nents(%d) < enabled chanes(%d)\n", dev_err(edma->fdev, "%s: nents(%d) < enabled chanes(%d)\n",
__func__, nents, num_chans); __func__, nents, num_chans);