crypto: qat - fix error path in add_update_sla()
Subsystems (2)
PATCH 1/1 crypto: qat - fix error path in add_update_sla()
The input argument sla_in is a pointer to a structure that contains the parameters of the SLA which is being added or updated. If this pointer is NULL, the function should return an error as the data required for the algorithm is not available.
By mistake, the logic jumps to the error path which dereferences the pointer.
This results in a warnings reported by the static analyzer Smatch when executed without a database:
drivers/crypto/intel/qat/qat_common/adf_rl.c:871 add_update_sla()
error: we previously assumed 'sla_in' could be null (see line 812)
This issue was not found in internal testing as the pointer cannot be NULL. The function add_update_sla() is only called (indirectly) by the rate limiting sysfs interface implementation in adf_sysfs_rl.c which ensures that the data structure is allocated and valid. This is also proven by the fact that Smatch executed with a database does not report such error.
Fix it by returning with error if the pointer sla_in is NULL.
--- drivers/crypto/intel/qat/qat_common/adf_rl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_rl.c +1 -2
@@ -812,8 +812,7 @@ static int add_update_sla(struct adf_accel_dev *accel_dev,if (!sla_in) {dev_warn (&GET_DEV (accel_dev),"SLA input data pointer is missing\n" ); - ret = -EFAULT ; - goto ret_err; +return -EFAULT ; }/* Input validation */
base-commit: 27265511a765f4380257319b0c088097b9cf1a71
Signature · 1 line
2.41.0
Herbert Xu
maintainerQuoted 22 lines · Damian Muszynski
The input argument
sla_inis a pointer to a structure that contains the parameters of the SLA which is being added or updated. If this pointer is NULL, the function should return an error as the data required for the algorithm is not available.
By mistake, the logic jumps to the error path which dereferences the pointer.This results in a warnings reported by the static analyzer Smatch when executed without a database:
drivers/crypto/intel/qat/qat_common/adf_rl.c:871add_update_sla()
error: we previously assumed 'sla_in' could be null (see line 812)This issue was not found in internal testing as the pointer cannot be NULL. The function
add_update_sla()is only called (indirectly) by the rate limiting sysfs interface implementation inadf_sysfs_rl.cwhich ensures that the data structure is allocated and valid. This is also proven by the fact that Smatch executed with a database does not report such error.Fix it by returning with error if the pointer
sla_inis NULL.
Quoted 7 lines
Fixes d9fb8408376e ("crypto: qat - add rate limiting feature to qat_4xxx")Reported-by Dan Carpenter <[email protected]>Signed-off-by Damian Muszynski <[email protected]>Reviewed-by Giovanni Cabiddu <[email protected]>--- drivers/crypto/intel/qat/qat_common/adf_rl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
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