Skip to contentSkip to conversation

crypto: qat - don't cast parameter in bit operations

PATCH In review Andy Shevchenko 3 participants 3 messages Feb 9, 2022 – Feb 18, 2022 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: qat - don't cast parameter in bit operations

While in this particular case it would not be a (critical) issue, the pattern itself is bad and error prone in case the location of the parameter is changed.

Don't cast parameter to unsigned long pointer in the bit operations. Instead copy to a local variable on stack of a proper type and use.

Fixes b4b7e67c917f ("crypto: qat - Intel(R) QAT ucode part of fw loader")
---
 drivers/crypto/qat/qat_common/qat_uclo.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/qat_uclo.c +6 -3
index 2026cc6be8f0..6356402a2c9e 100644
@@ -387,7 +387,9 @@ static int qat_uclo_init_ustore(struct icp_qat_fw_loader_handle *handle,
 	page = image->page;
 
 	for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) {
-		if (!test_bit(ae, (unsigned long *)&uof_image->ae_assigned))
+		unsigned long ae_assigned = uof_image->ae_assigned;
+
+		if (!test_bit(ae, &ae_assigned))
 			continue;
 
 		if (!test_bit(ae, &cfg_ae_mask))
@@ -664,8 +666,9 @@ static int qat_uclo_map_ae(struct icp_qat_fw_loader_handle *handle, int max_ae)
 			continue;
 
 		for (i = 0; i < obj_handle->uimage_num; i++) {
-			if (!test_bit(ae, (unsigned long *)
-			&obj_handle->ae_uimage[i].img_ptr->ae_assigned))
+			unsigned long ae_assigned = obj_handle->ae_uimage[i].img_ptr->ae_assigned;
+
+			if (!test_bit(ae, &ae_assigned))
 				continue;
 			mflag = 1;
 			if (qat_uclo_init_ae_data(obj_handle, ae, i))
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

Thanks Andy.

Quoted 9 lines · Andy Shevchenko

While in this particular case it would not be a (critical) issue, the pattern itself is bad and error prone in case the location of the parameter is changed.

Don't cast parameter to unsigned long pointer in the bit operations. Instead copy to a local variable on stack of a proper type and use.

Fixes b4b7e67c917f ("crypto: qat - Intel(R) QAT ucode part of fw loader")
Signature · 1 line
Giovanni
maintainer
#2 lore raw
In reply to Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

While in this particular case it would not be a (critical) issue, the pattern itself is bad and error prone in case the location of the parameter is changed.

Quoted 8 lines

Don't cast parameter to unsigned long pointer in the bit operations. Instead copy to a local variable on stack of a proper type and use.

Fixes b4b7e67c917f ("crypto: qat - Intel(R) QAT ucode part of fw loader")
---
 drivers/crypto/qat/qat_common/qat_uclo.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 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