From b3bfce4122a9447377a5e37418443222f09f61ac Mon Sep 17 00:00:00 2001 From: Nagarjuna Kristam Date: Fri, 24 Mar 2023 11:55:46 +0530 Subject: [PATCH] PCI: edma_test: Fix Coverity issues Validate num_chans before using for division Bug 3956683 Signed-off-by: Nagarjuna Kristam Change-Id: I8abca2a251748711f07ffc14d71b1601fa73806f Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2876298 Reviewed-by: svcacv Reviewed-by: Manikanta Maddireddy Reviewed-by: Bitan Biswas GVS: Gerrit_Virtual_Submit --- include/linux/tegra-pcie-edma-test-common.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/tegra-pcie-edma-test-common.h b/include/linux/tegra-pcie-edma-test-common.h index 16fdd78b..12b693ac 100644 --- a/include/linux/tegra-pcie-edma-test-common.h +++ b/include/linux/tegra-pcie-edma-test-common.h @@ -2,7 +2,7 @@ /* * 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 @@ -196,7 +196,9 @@ static int edmalib_common_test(struct edmalib_common *edma) return 0; } - nents_per_ch = nents / num_chans; + if (num_chans != 0) + nents_per_ch = nents / num_chans; + if (nents_per_ch == 0) { dev_err(edma->fdev, "%s: nents(%d) < enabled chanes(%d)\n", __func__, nents, num_chans);