On Sun, Jun 26, 2022 at 02:37:22PM -0700, Eric Biggers wrote: > On Fri, Jun 24, 2022 at 10:12:52PM +0800, Ming Lei wrote: > > diff --git a/block/blk-crypto.c b/block/blk-crypto.c > > index a496aaef85ba..caae2f429fc7 100644 > > --- a/block/blk-crypto.c > > +++ b/block/blk-crypto.c > > @@ -134,6 +134,21 @@ void bio_crypt_dun_increment(u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE], > > } > > } > > > > +/* Decrements @dun by @dec, treating @dun as a multi-limb integer. */ > > +void bio_crypt_dun_decrement(u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE], > > + unsigned int dec) > > +{ > > + int i; > > + > > + for (i = 0; dec && i < BLK_CRYPTO_DUN_ARRAY_SIZE; i++) { > > + dun[i] -= dec; > > + if (dun[i] > inc) > > + dec = 1; > > + else > > + dec = 0; > > + } > > +} > > This doesn't compile. Also this doesn't handle underflow into the next limb > correctly. A correct version would be: > > u64 prev = dun[i]; > > dun[i] -= dec; > if (dun[i] > prev) > dec = 1; > else > dec = 0; You are right, thanks for the review! Thanks, Ming -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel