regmap: Fix for v6.10

Guenter ran with memory sanitisers and found an issue in the new KUnit
 tests that Richard added where an assumption in older test code was
 exposed, this was fixed quickly by Richard.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmZPLK0ACgkQJNaLcl1U
 h9CZGwf+PvFLBs2eNVOPhe6fub6KmOtrzBxp20QhY3i/SFUFx8BllCNffzQRV3wN
 6JLeCK3RAkpe77sjFCKWsr6Tb/IDKAGCJvA9q+/NsU0UQThiUfsr7vcOB4nw8hY3
 d1P8dHJR89ux3XarEg5JYJHjZi02u9hg+0yub9PP/s6pfk0LVGgbA0mHR2fNFp2S
 xx8KIVm+qonAqyyDxn3jrhTCvcwvQg+0Y7cPVSaEA3YedVsDzwzH2i9Lo3GN/QDM
 vjgy84JnlIo1SQAWMX6Xt6hCX7puGOZXpJHcQxOe5RtL6T+vUmzNelJLPLB/vCbi
 IWy+yiQG6e4ckSiwB9pwIOExQXM+nA==
 =sKgs
 -----END PGP SIGNATURE-----

Merge tag 'regmap-fix-v6.10-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap

Pull regmap fix from Mark Brown:
 "Guenter ran with memory sanitisers and found an issue in the new KUnit
  tests that Richard added where an assumption in older test code was
  exposed, this was fixed quickly by Richard"

* tag 'regmap-fix-v6.10-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
  regmap: kunit: Fix array overflow in stride() test
This commit is contained in:
Linus Torvalds 2024-05-23 13:38:31 -07:00
commit 09f8f2c4ca

View File

@ -609,12 +609,19 @@ static void stride(struct kunit *test)
config.reg_stride = 2; config.reg_stride = 2;
config.num_reg_defaults = BLOCK_TEST_SIZE / 2; config.num_reg_defaults = BLOCK_TEST_SIZE / 2;
/*
* Allow one extra register so that the read/written arrays
* are sized big enough to include an entry for the odd
* address past the final reg_default register.
*/
config.max_register = BLOCK_TEST_SIZE;
map = gen_regmap(test, &config, &data); map = gen_regmap(test, &config, &data);
KUNIT_ASSERT_FALSE(test, IS_ERR(map)); KUNIT_ASSERT_FALSE(test, IS_ERR(map));
if (IS_ERR(map)) if (IS_ERR(map))
return; return;
/* Only even registers can be accessed, try both read and write */ /* Only even addresses can be accessed, try both read and write */
for (i = 0; i < BLOCK_TEST_SIZE; i++) { for (i = 0; i < BLOCK_TEST_SIZE; i++) {
data->read[i] = false; data->read[i] = false;
data->written[i] = false; data->written[i] = false;