Skip to content

Commit 80b6104

Browse files
David Laightherbertx
authored andcommitted
crypto: lib/mpi - use min() instead of min_t()
min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight <david.laight.linux@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 14ca8ce commit 80b6104

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/crypto/mpi/mpicoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes)
398398

399399
while (sg_miter_next(&miter)) {
400400
buff = miter.addr;
401-
len = min_t(unsigned, miter.length, nbytes);
401+
len = min(miter.length, nbytes);
402402
nbytes -= len;
403403

404404
for (x = 0; x < len; x++) {

0 commit comments

Comments
 (0)