Oh, this is nice. So, there are two (more?) options I see to mitigate
the issue:
- carefully copy the garbage from the stack to the expected values
   (effectively merge the whatever is on stack with the expected value)
- allocate buffers on heap

The latter seems the easiest and right thing to do (since we can't really
predict if the stack pattern is the same or bitmap APIs scatters the bits
just on top of the respective set or clear ones over that pattern).

I will send a patch, thanks for the report and analysis!



The following change fixes the issue for me:

diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 69813c10e6c0b..448c3eb48a4a8 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -392,6 +392,7 @@ static void __init test_bitmap_sg(void)

      /* Scatter/gather relationship */
      bitmap_zero(bmap_tmp, 100);
+    bitmap_zero(bmap_res, 100);
      bitmap_gather(bmap_tmp, bmap_scatter, sg_mask, nbits);
      bitmap_scatter(bmap_res, bmap_tmp, sg_mask, nbits);
      expect_eq_bitmap(bmap_scatter, bmap_res, 100);

Patch applied on top of v7.2-rc2.

I can confirm Christophes patch fixes the issue for me. Thanks!

Regards,
Erhard

Reply via email to