Skip to content

Commit 6424da7

Browse files
nivasvmherbertx
authored andcommitted
crypto: qat - extend scope of lock in adf_cfg_add_key_value_param()
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]>
1 parent d26cb4f commit 6424da7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/crypto/intel/qat/qat_common/adf_cfg.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,19 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev,
290290
* 3. if the key exists with the same value, then return without doing
291291
* anything (the newly created key_val is freed).
292292
*/
293+
down_write(&cfg->lock);
293294
if (!adf_cfg_key_val_get(accel_dev, section_name, key, temp_val)) {
294295
if (strncmp(temp_val, key_val->val, sizeof(temp_val))) {
295296
adf_cfg_keyval_remove(key, section);
296297
} else {
297298
kfree(key_val);
298-
return 0;
299+
goto out;
299300
}
300301
}
301302

302-
down_write(&cfg->lock);
303303
adf_cfg_keyval_add(key_val, section);
304+
305+
out:
304306
up_write(&cfg->lock);
305307
return 0;
306308
}

0 commit comments

Comments
 (0)