linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] crypto: qat - don't cast parameter in bit operations
@ 2022-02-09 18:00 Andy Shevchenko
  2022-02-09 20:47 ` Giovanni Cabiddu
  2022-02-18  5:37 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-02-09 18:00 UTC (permalink / raw)
  To: Giovanni Cabiddu, Jack Xu, Herbert Xu, Zhehui Xiang, qat-linux,
	linux-crypto, linux-kernel
  Cc: David S. Miller, 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")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/crypto/qat/qat_common/qat_uclo.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/qat_uclo.c b/drivers/crypto/qat/qat_common/qat_uclo.c
index 2026cc6be8f0..6356402a2c9e 100644
--- a/drivers/crypto/qat/qat_common/qat_uclo.c
+++ b/drivers/crypto/qat/qat_common/qat_uclo.c
@@ -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))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] crypto: qat - don't cast parameter in bit operations
  2022-02-09 18:00 [PATCH v1 1/1] crypto: qat - don't cast parameter in bit operations Andy Shevchenko
@ 2022-02-09 20:47 ` Giovanni Cabiddu
  2022-02-18  5:37 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Giovanni Cabiddu @ 2022-02-09 20:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jack Xu, Herbert Xu, Zhehui Xiang, qat-linux, linux-crypto,
	linux-kernel, David S. Miller

Thanks Andy.

On Wed, Feb 09, 2022 at 08:00:47PM +0200, Andy Shevchenko wrote:
> 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")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>

-- 
Giovanni

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] crypto: qat - don't cast parameter in bit operations
  2022-02-09 18:00 [PATCH v1 1/1] crypto: qat - don't cast parameter in bit operations Andy Shevchenko
  2022-02-09 20:47 ` Giovanni Cabiddu
@ 2022-02-18  5:37 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2022-02-18  5:37 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Giovanni Cabiddu, Jack Xu, Zhehui Xiang, qat-linux, linux-crypto,
	linux-kernel, David S. Miller

On Wed, Feb 09, 2022 at 08:00:47PM +0200, Andy Shevchenko wrote:
> 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")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/crypto/qat/qat_common/qat_uclo.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-18  5:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 18:00 [PATCH v1 1/1] crypto: qat - don't cast parameter in bit operations Andy Shevchenko
2022-02-09 20:47 ` Giovanni Cabiddu
2022-02-18  5:37 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).