Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 472b04444cd3 ("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>

authored by

Thomas Fourier and committed by
Herbert Xu
4e53be21 3ed63344

+4 -1
+4 -1
drivers/crypto/intel/keembay/keembay-ocs-hcu-core.c
··· 232 232 struct device *dev = rctx->hcu_dev->dev; 233 233 unsigned int remainder = 0; 234 234 unsigned int total; 235 - size_t nents; 235 + int nents; 236 236 size_t count; 237 237 int rc; 238 238 int i; ··· 252 252 253 253 /* Determine the number of scatter gather list entries to process. */ 254 254 nents = sg_nents_for_len(req->src, rctx->sg_data_total - remainder); 255 + 256 + if (nents < 0) 257 + return nents; 255 258 256 259 /* If there are entries to process, map them. */ 257 260 if (nents) {