crypto: ccree: Correctly handle return of sg_nents_for_len
Subsystems (2)
PATCH 1/1 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 <[email protected]>
--- drivers/crypto/ccree/cc_buffer_mgr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/crypto/ccree/cc_buffer_mgr.c +5 -1
@@ -1235,6 +1235,7 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx,int rc =0 ;u32 dummy =0 ;u32 mapped_nents =0 ; +int sg_nents;dev_dbg (dev," update params : curr_buff=%p curr_buff_cnt=0x%X nbytes=0x%X src=%p curr_index=%u\n" , curr_buff, *curr_buff_cnt, nbytes, src, areq_ctx->buff_index);
@@ -1248,7 +1249,10 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx,if (total_in_len < block_size) {dev_dbg (dev," less than one block: curr_buff=%p *curr_buff_cnt=0x%X copy_to=%p\n" , curr_buff, *curr_buff_cnt, &curr_buff[*curr_buff_cnt]); - areq_ctx->in_nents =sg_nents_for_len (src, nbytes); + sg_nents =sg_nents_for_len (src, nbytes); +if (sg_nents <0 ) +return sg_nents; + areq_ctx->in_nents = sg_nents;sg_copy_to_buffer (src, areq_ctx->in_nents, &curr_buff[*curr_buff_cnt], nbytes); *curr_buff_cnt += nbytes;
Signature · 1 line
2.50.1.windows.1
Herbert Xu
maintainerQuoted 4 lines · Haotian Zhang
Fix error handling in
cc_map_hash_request_updatewheresg_nents_for_lenreturn value was assigned to u32, converting negative errors to large positive values before passing tosg_copy_to_buffer.
Quoted 8 lines
Check
sg_nents_for_lenreturn value and propagate errors before assigning toareq_ctx->in_nents.Fixes b7ec8530687a ("crypto: ccree - use std api when possible")Signed-off-by Haotian Zhang <[email protected]>--- drivers/crypto/ccree/cc_buffer_mgr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt