Skip to content

Commit bde9079

Browse files
horiagherbertx
authored andcommitted
crypto: talitos - avoid out of bound scatterlist iterator
Check return value of scatterlist_sg_next(), i.e. don't rely solely on number of bytes to be processed or number of scatterlist entries. Signed-off-by: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 69d9cd8 commit bde9079

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/crypto/talitos.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count,
10651065
{
10661066
int n_sg = sg_count;
10671067

1068-
while (n_sg--) {
1068+
while (sg && n_sg--) {
10691069
to_talitos_ptr(link_tbl_ptr, sg_dma_address(sg), 0);
10701070
link_tbl_ptr->len = cpu_to_be16(sg_dma_len(sg));
10711071
link_tbl_ptr->j_extent = 0;
@@ -1254,7 +1254,7 @@ static int sg_count(struct scatterlist *sg_list, int nbytes, bool *chained)
12541254
int sg_nents = 0;
12551255

12561256
*chained = false;
1257-
while (nbytes > 0) {
1257+
while (nbytes > 0 && sg) {
12581258
sg_nents++;
12591259
nbytes -= sg->length;
12601260
if (!sg_is_last(sg) && (sg + 1)->length == 0)

0 commit comments

Comments
 (0)