提交 57adbeea 编写于 作者: B Bo Yan 提交者: Greg Kroah-Hartman

coresight: etm4x: Fix bit shifting

ctxid_pid and vmid_val in config are of type u64. When an integer
0xFF is being left shifted more than 32 bits, the behavior is
undefined. The fix is to specify 0xFF as an unsigned long.

Detected by Coverity scan: CID 37650, 37651 (Bad bit shift operation)
Signed-off-by: NBo Yan <byan@nvidia.com>
Signed-off-by: NMathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 831c326f
...@@ -1780,7 +1780,7 @@ static ssize_t ctxid_masks_store(struct device *dev, ...@@ -1780,7 +1780,7 @@ static ssize_t ctxid_masks_store(struct device *dev,
*/ */
for (j = 0; j < 8; j++) { for (j = 0; j < 8; j++) {
if (maskbyte & 1) if (maskbyte & 1)
config->ctxid_pid[i] &= ~(0xFF << (j * 8)); config->ctxid_pid[i] &= ~(0xFFUL << (j * 8));
maskbyte >>= 1; maskbyte >>= 1;
} }
/* Select the next ctxid comparator mask value */ /* Select the next ctxid comparator mask value */
...@@ -1963,7 +1963,7 @@ static ssize_t vmid_masks_store(struct device *dev, ...@@ -1963,7 +1963,7 @@ static ssize_t vmid_masks_store(struct device *dev,
*/ */
for (j = 0; j < 8; j++) { for (j = 0; j < 8; j++) {
if (maskbyte & 1) if (maskbyte & 1)
config->vmid_val[i] &= ~(0xFF << (j * 8)); config->vmid_val[i] &= ~(0xFFUL << (j * 8));
maskbyte >>= 1; maskbyte >>= 1;
} }
/* Select the next vmid comparator mask value */ /* Select the next vmid comparator mask value */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册