crypto: ccp - Protect against poorly marked end of sg list
[deliverable/linux.git] / drivers / crypto / ccp / ccp-ops.c
index 542453c9ba1c87c2885090a3ec280b8df30ccb60..d09c6c4af4aabfcba7cdd48e33c6d88ab80b5453 100644 (file)
@@ -52,7 +52,7 @@ struct ccp_dm_workarea {
 
 struct ccp_sg_workarea {
        struct scatterlist *sg;
-       unsigned int nents;
+       int nents;
 
        struct scatterlist *dma_sg;
        struct device *dma_dev;
@@ -495,7 +495,10 @@ static int ccp_init_sg_workarea(struct ccp_sg_workarea *wa, struct device *dev,
        if (!sg)
                return 0;
 
-       wa->nents = sg_nents(sg);
+       wa->nents = sg_nents_for_len(sg, len);
+       if (wa->nents < 0)
+               return wa->nents;
+
        wa->bytes_left = len;
        wa->sg_used = 0;
 
This page took 0.024796 seconds and 5 git commands to generate.