aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mpi/mpicoder.c
diff options
context:
space:
mode:
authorStephan Mueller <smueller@chronox.de>2015-10-18 06:45:18 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-10-20 10:10:47 -0400
commit63349d02c195030f97c9c2000bbf32539056316f (patch)
treeb6555ee222c808f802b32031ad272a6e7ad6acfe /lib/mpi/mpicoder.c
parent4a4b0bad0653a0dce876987f7487b2c5e3ecb05f (diff)
lib/mpi: fix off by one in mpi_read_raw_from_sgl
The patch fixes the analysis of the input data which contains an off by one. The issue is visible when the SGL contains one byte per SG entry. The code for checking for zero bytes does not operate on the data byte. Signed-off-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'lib/mpi/mpicoder.c')
-rw-r--r--lib/mpi/mpicoder.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
index c20ef27ad876..c7e0a705eecf 100644
--- a/lib/mpi/mpicoder.c
+++ b/lib/mpi/mpicoder.c
@@ -446,8 +446,11 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int len)
446 const u8 *buff = sg_virt(sg); 446 const u8 *buff = sg_virt(sg);
447 int len = sg->length; 447 int len = sg->length;
448 448
449 while (len-- && !*buff++) 449 while (len && !*buff) {
450 lzeros++; 450 lzeros++;
451 len--;
452 buff++;
453 }
451 454
452 if (len && *buff) 455 if (len && *buff)
453 break; 456 break;