]> git.droids-corp.org - dpdk.git/commitdiff
raw/ioat: fix queue index calculation
authorBruce Richardson <bruce.richardson@intel.com>
Thu, 5 Nov 2020 10:41:04 +0000 (10:41 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 13 Nov 2020 14:30:08 +0000 (15:30 +0100)
Coverity flags a possible problem where the 8-bit wq_idx value may have
errors when shifted and sign-extended to pointer size. Since this can
only occur if the shift index is larger than any expected value from
hardware, it's unlikely to cause any real problems, but we can eliminate
any possible errors, and the coverity issue, by explicitly typecasting
the uint8_t value to uintptr_t before any shift operations occur.

Coverity issue: 363695
Fixes: a33969462135 ("raw/ioat: fix work-queue config size")
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
drivers/raw/ioat/idxd_pci.c

index 99ecfbbb4896bef03402c64772b837d07275faa8..01623f33f67b3ba35ef1d86f1300969abc01a5ac 100644 (file)
@@ -47,7 +47,8 @@ idxd_pci_dev_command(struct idxd_rawdev *idxd, enum rte_idxd_cmds command)
 static uint32_t *
 idxd_get_wq_cfg(struct idxd_pci_common *pci, uint8_t wq_idx)
 {
-       return RTE_PTR_ADD(pci->wq_regs_base, wq_idx << (5 + pci->wq_cfg_sz));
+       return RTE_PTR_ADD(pci->wq_regs_base,
+                       (uintptr_t)wq_idx << (5 + pci->wq_cfg_sz));
 }
 
 static int