Skip to content

Commit

Permalink
crypto: qat - extend scope of lock in adf_cfg_add_key_value_param()
Browse files Browse the repository at this point in the history
[ Upstream commit 6424da7 ]

The function adf_cfg_add_key_value_param() attempts to access and modify
the key value store of the driver without locking.

Extend the scope of cfg->lock to avoid a potential race condition.

Fixes: 92bf269 ("crypto: qat - change behaviour of adf_cfg_add_key_value_param()")
Signed-off-by: Nivas Varadharajan Mugunthakumar <[email protected]>
Signed-off-by: Giovanni Cabiddu <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
nivasvm authored and gregkh committed Aug 3, 2024
1 parent 5b19974 commit d6997d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/crypto/qat/qat_common/adf_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,19 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev,
* 3. if the key exists with the same value, then return without doing
* anything (the newly created key_val is freed).
*/
down_write(&cfg->lock);
if (!adf_cfg_key_val_get(accel_dev, section_name, key, temp_val)) {
if (strncmp(temp_val, key_val->val, sizeof(temp_val))) {
adf_cfg_keyval_remove(key, section);
} else {
kfree(key_val);
return 0;
goto out;
}
}

down_write(&cfg->lock);
adf_cfg_keyval_add(key_val, section);

out:
up_write(&cfg->lock);
return 0;
}
Expand Down

0 comments on commit d6997d4

Please sign in to comment.