mirror of
https://github.com/torvalds/linux.git
synced 2026-01-24 23:16:46 +00:00
crypto: keembay - Add missing check after sg_nents_for_len()
sg_nents_for_len() returns an int which is negative in case of error.
Fixes: 472b04444c ("crypto: keembay - Add Keem Bay OCS HCU driver")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
3ed6334465
commit
4e53be21dd
@@ -232,7 +232,7 @@ static int kmb_ocs_dma_prepare(struct ahash_request *req)
|
||||
struct device *dev = rctx->hcu_dev->dev;
|
||||
unsigned int remainder = 0;
|
||||
unsigned int total;
|
||||
size_t nents;
|
||||
int nents;
|
||||
size_t count;
|
||||
int rc;
|
||||
int i;
|
||||
@@ -253,6 +253,9 @@ static int kmb_ocs_dma_prepare(struct ahash_request *req)
|
||||
/* Determine the number of scatter gather list entries to process. */
|
||||
nents = sg_nents_for_len(req->src, rctx->sg_data_total - remainder);
|
||||
|
||||
if (nents < 0)
|
||||
return nents;
|
||||
|
||||
/* If there are entries to process, map them. */
|
||||
if (nents) {
|
||||
rctx->sg_dma_nents = dma_map_sg(dev, req->src, nents,
|
||||
|
||||
Reference in New Issue
Block a user