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

Configure Feed

Select the types of activity you want to include in your feed.

crypto: ccree - Correctly handle return of sg_nents_for_len

Fix error handling in cc_map_hash_request_update where sg_nents_for_len
return value was assigned to u32, converting negative errors to large
positive values before passing to sg_copy_to_buffer.

Check sg_nents_for_len return value and propagate errors before
assigning to areq_ctx->in_nents.

Fixes: b7ec8530687a ("crypto: ccree - use std api when possible")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Haotian Zhang and committed by
Herbert Xu
8700ce07 e9eb5203

+5 -1
+5 -1
drivers/crypto/ccree/cc_buffer_mgr.c
··· 1235 1235 int rc = 0; 1236 1236 u32 dummy = 0; 1237 1237 u32 mapped_nents = 0; 1238 + int sg_nents; 1238 1239 1239 1240 dev_dbg(dev, " update params : curr_buff=%p curr_buff_cnt=0x%X nbytes=0x%X src=%p curr_index=%u\n", 1240 1241 curr_buff, *curr_buff_cnt, nbytes, src, areq_ctx->buff_index); ··· 1249 1248 if (total_in_len < block_size) { 1250 1249 dev_dbg(dev, " less than one block: curr_buff=%p *curr_buff_cnt=0x%X copy_to=%p\n", 1251 1250 curr_buff, *curr_buff_cnt, &curr_buff[*curr_buff_cnt]); 1252 - areq_ctx->in_nents = sg_nents_for_len(src, nbytes); 1251 + sg_nents = sg_nents_for_len(src, nbytes); 1252 + if (sg_nents < 0) 1253 + return sg_nents; 1254 + areq_ctx->in_nents = sg_nents; 1253 1255 sg_copy_to_buffer(src, areq_ctx->in_nents, 1254 1256 &curr_buff[*curr_buff_cnt], nbytes); 1255 1257 *curr_buff_cnt += nbytes;