Do not call dma_unmap_sg() for scatterlists that were not mapped
successfully.
Fixes: 5de8875281e1 ("crypto: sahara - Add driver for SAHARA2 accelerator.")
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
                         DMA_TO_DEVICE);
        if (!ret) {
                dev_err(dev->device, "couldn't map in sg\n");
-               goto unmap_in;
+               return -EINVAL;
        }
+
        ret = dma_map_sg(dev->device, dev->out_sg, dev->nb_out_sg,
                         DMA_FROM_DEVICE);
        if (!ret) {
                dev_err(dev->device, "couldn't map out sg\n");
-               goto unmap_out;
+               goto unmap_in;
        }
 
        /* Create input links */
 
        return 0;
 
-unmap_out:
-       dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg,
-               DMA_FROM_DEVICE);
 unmap_in:
        dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
                DMA_TO_DEVICE);