Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bitmap: Add test for out-of-boundary modifications for scatter & gather

Make sure that bitmap_scatter() and bitmap_gather() do not modify
the bits outside of the given nbits span.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Yury Norov <ynorov@nvidia.com>

authored by

Andy Shevchenko and committed by
Yury Norov
6b5a4b68 c3692998

+7 -3
+7 -3
lib/test_bitmap.c
··· 354 354 355 355 static const unsigned long sg_mask[] __initconst = { 356 356 BITMAP_FROM_U64(0x000000000000035aULL), 357 + BITMAP_FROM_U64(0x0000000000000000ULL), 357 358 }; 358 359 359 360 static const unsigned long sg_src[] __initconst = { 360 361 BITMAP_FROM_U64(0x0000000000000667ULL), 362 + BITMAP_FROM_U64(0x0000000000000000ULL), 361 363 }; 362 364 363 365 static const unsigned long sg_gather_exp[] __initconst = { 364 366 BITMAP_FROM_U64(0x0000000000000029ULL), 367 + BITMAP_FROM_U64(0x0000000000000000ULL), 365 368 }; 366 369 367 370 static const unsigned long sg_scatter_exp[] __initconst = { 368 371 BITMAP_FROM_U64(0x000000000000021aULL), 372 + BITMAP_FROM_U64(0x0000000000000000ULL), 369 373 }; 370 374 371 375 static void __init test_bitmap_sg(void) ··· 383 379 /* Simple gather call */ 384 380 bitmap_zero(bmap_gather, 100); 385 381 bitmap_gather(bmap_gather, sg_src, sg_mask, nbits); 386 - expect_eq_bitmap(sg_gather_exp, bmap_gather, nbits); 382 + expect_eq_bitmap(sg_gather_exp, bmap_gather, 100); 387 383 388 384 /* Simple scatter call */ 389 385 bitmap_zero(bmap_scatter, 100); 390 386 bitmap_scatter(bmap_scatter, sg_src, sg_mask, nbits); 391 - expect_eq_bitmap(sg_scatter_exp, bmap_scatter, nbits); 387 + expect_eq_bitmap(sg_scatter_exp, bmap_scatter, 100); 392 388 393 389 /* Scatter/gather relationship */ 394 390 bitmap_zero(bmap_tmp, 100); 395 391 bitmap_gather(bmap_tmp, bmap_scatter, sg_mask, nbits); 396 392 bitmap_scatter(bmap_res, bmap_tmp, sg_mask, nbits); 397 - expect_eq_bitmap(bmap_scatter, bmap_res, nbits); 393 + expect_eq_bitmap(bmap_scatter, bmap_res, 100); 398 394 } 399 395 400 396 #define PARSE_TIME 0x1