Skip to contentSkip to conversation

hw/display/exynos4210_fimd: Fix bit-swapping code

PATCH In review Peter Maydell 1 participant 4 messages May 29, 2015 – Jun 12, 2015 Arm Samsung Exynos

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/display/exynos4210_fimd: Fix bit-swapping code

fimd_swap_data() includes code to reverse the bits in a 64-bit integer, but an off-by-one error meant that it would try to shift off the top of the integer. Correct the bug (spotted by Coverity).

---
Compile-tested only, I have no exynos images to test with.

 hw/display/exynos4210_fimd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/exynos4210_fimd.c +1 -1
index 45c62af..3e59ee4 100644
@@ -337,7 +337,7 @@ static inline void fimd_swap_data(unsigned int swap_ctl, uint64_t *data)
     if (swap_ctl & FIMD_WINCON_SWAP_BITS) {
         res = 0;
         for (i = 0; i < 64; i++) {
-            if (x & (1ULL << (64 - i))) {
+            if (x & (1ULL << (63 - i))) {
                 res |= (1ULL << i);
             }
         }
Signature · 1 line
1.9.1
#1 lore raw
Quoted 8 lines · Peter Maydell

fimd_swap_data() includes code to reverse the bits in a 64-bit integer, but an off-by-one error meant that it would try to shift off the top of the integer. Correct the bug (spotted by Coverity).

---
Compile-tested only, I have no exynos images to test with.

I see that all three samsung.com addresses in MAINTAINERS for the exynos board bounce :-(

-- PMM

#2 lore raw
In reply to Peter Maydell

Ping for either patch review or suggestions for updating the MAINTAINERS section for this board?

thanks
-- PMM

Quoted 29 lines · Peter Maydell

fimd_swap_data() includes code to reverse the bits in a 64-bit integer, but an off-by-one error meant that it would try to shift off the top of the integer. Correct the bug (spotted by Coverity).

---
Compile-tested only, I have no exynos images to test with.

 hw/display/exynos4210_fimd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/exynos4210_fimd.c +1 -2
index 45c62af..3e59ee4 100644
@@ -337,7 +337,7 @@ static inline void fimd_swap_data(unsigned int swap_ctl, uint64_t *data)
     if (swap_ctl & FIMD_WINCON_SWAP_BITS) {
         res = 0;
         for (i = 0; i < 64; i++) {
-            if (x & (1ULL << (64 - i))) {
+            if (x & (1ULL << (63 - i))) {
                 res |= (1ULL << i);
             }
         }
--

1.9.1

#3 lore raw

Deafening silence, so I'm just going to apply this to target-arm.next.

-- PMM

Quoted 34 lines · Peter Maydell

Ping for either patch review or suggestions for updating the MAINTAINERS section for this board?

thanks
-- PMM

Quoted 27 lines · Peter Maydell

fimd_swap_data() includes code to reverse the bits in a 64-bit integer, but an off-by-one error meant that it would try to shift off the top of the integer. Correct the bug (spotted by Coverity).

---
Compile-tested only, I have no exynos images to test with.

 hw/display/exynos4210_fimd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/exynos4210_fimd.c +1 -2
index 45c62af..3e59ee4 100644
@@ -337,7 +337,7 @@ static inline void fimd_swap_data(unsigned int swap_ctl, uint64_t *data)
     if (swap_ctl & FIMD_WINCON_SWAP_BITS) {
         res = 0;
         for (i = 0; i < 64; i++) {
-            if (x & (1ULL << (64 - i))) {
+            if (x & (1ULL << (63 - i))) {
                 res |= (1ULL << i);
             }
         }
--

1.9.1