2023-11-28 18:41:33

by Damian Muszynski

[permalink] [raw]
Subject: [PATCH] crypto: qat - fix mutex ordering in adf_rl

If the function validate_user_input() returns an error, the error path
attempts to unlock an unacquired mutex.
Acquire the mutex before calling validate_user_input(). This is not
strictly necessary but simplifies the code.

Fixes: d9fb8408376e ("crypto: qat - add rate limiting feature to qat_4xxx")
Signed-off-by: Damian Muszynski <[email protected]>
Reviewed-by: Giovanni Cabiddu <[email protected]>
---
drivers/crypto/intel/qat/qat_common/adf_rl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/intel/qat/qat_common/adf_rl.c b/drivers/crypto/intel/qat/qat_common/adf_rl.c
index f2de3cd7d05d..de1b214dba1f 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_rl.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_rl.c
@@ -815,13 +815,13 @@ static int add_update_sla(struct adf_accel_dev *accel_dev,
return -EFAULT;
}

+ mutex_lock(&rl_data->rl_lock);
+
/* Input validation */
ret = validate_user_input(accel_dev, sla_in, is_update);
if (ret)
goto ret_err;

- mutex_lock(&rl_data->rl_lock);
-
if (is_update) {
ret = validate_sla_id(accel_dev, sla_in->sla_id);
if (ret)

base-commit: ed628a28e67c93d65400e7f00e0ff5d4f7a87070
--
2.41.0



2023-12-08 04:34:30

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: qat - fix mutex ordering in adf_rl

On Tue, Nov 28, 2023 at 06:39:30PM +0100, Damian Muszynski wrote:
> If the function validate_user_input() returns an error, the error path
> attempts to unlock an unacquired mutex.
> Acquire the mutex before calling validate_user_input(). This is not
> strictly necessary but simplifies the code.
>
> Fixes: d9fb8408376e ("crypto: qat - add rate limiting feature to qat_4xxx")
> Signed-off-by: Damian Muszynski <[email protected]>
> Reviewed-by: Giovanni Cabiddu <[email protected]>
> ---
> drivers/crypto/intel/qat/qat_common/adf_rl.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt