All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request
@ 2018-03-01 20:50 Krzysztof Kozlowski
  2018-03-01 20:50 ` [PATCH 2/4] crypto: omap-sham - Fix misleading indentation Krzysztof Kozlowski
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2018-03-01 20:50 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Krzysztof Kozlowski,
	Vladimir Zapolskiy, Kamil Konieczny, Tero Kristo, linux-crypto,
	linux-kernel, linux-samsung-soc

ahash_request 'req' argument passed by the caller
omap_sham_handle_queue() cannot be NULL here because it is obtained from
non-NULL pointer via container_of().

This fixes smatch warning:
    drivers/crypto/omap-sham.c:812 omap_sham_prepare_request() warn: variable dereferenced before check 'req' (see line 805)

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/crypto/omap-sham.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index 86b89ace836f..7650b1b449bb 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -809,9 +809,6 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update)
 	bool final = rctx->flags & BIT(FLAGS_FINUP);
 	int xmit_len, hash_later;
 
-	if (!req)
-		return 0;
-
 	bs = get_block_size(rctx);
 
 	if (update)
-- 
2.7.4

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

* [PATCH 2/4] crypto: omap-sham - Fix misleading indentation
  2018-03-01 20:50 [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request Krzysztof Kozlowski
@ 2018-03-01 20:50 ` Krzysztof Kozlowski
  2018-03-05  8:59     ` Tero Kristo
  2018-03-01 20:50 ` [PATCH 3/4] crypto: s5p-sss: Remove useless check for non-null request Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Krzysztof Kozlowski @ 2018-03-01 20:50 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Krzysztof Kozlowski,
	Vladimir Zapolskiy, Kamil Konieczny, Tero Kristo, linux-crypto,
	linux-kernel, linux-samsung-soc

Commit 8043bb1ae03c ("crypto: omap-sham - convert driver logic to use
sgs for data xmit") removed the if() clause leaving the statement as is.
The intention was in that case to finish the request always so the goto
instruction seems sensible.

Remove the indentation to fix Smatch warning:
    drivers/crypto/omap-sham.c:1761 omap_sham_done_task() warn: inconsistent indenting

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/crypto/omap-sham.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index 7650b1b449bb..6cb6ab6f52c0 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -1758,7 +1758,7 @@ static void omap_sham_done_task(unsigned long data)
 		if (test_and_clear_bit(FLAGS_OUTPUT_READY, &dd->flags)) {
 			/* hash or semi-hash ready */
 			clear_bit(FLAGS_DMA_READY, &dd->flags);
-				goto finish;
+			goto finish;
 		}
 	}
 
-- 
2.7.4

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

* [PATCH 3/4] crypto: s5p-sss: Remove useless check for non-null request
  2018-03-01 20:50 [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request Krzysztof Kozlowski
  2018-03-01 20:50 ` [PATCH 2/4] crypto: omap-sham - Fix misleading indentation Krzysztof Kozlowski
@ 2018-03-01 20:50 ` Krzysztof Kozlowski
  2018-03-01 20:50 ` [PATCH 4/4] crypto: s5p-sss - Constify pointed data (arguments and local variables) Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2018-03-01 20:50 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Krzysztof Kozlowski,
	Vladimir Zapolskiy, Kamil Konieczny, Tero Kristo, linux-crypto,
	linux-kernel, linux-samsung-soc

ahash_request 'req' argument passed by the caller
s5p_hash_handle_queue() cannot be NULL here because it is obtained from
non-NULL pointer via container_of().

This fixes smatch warning:
    drivers/crypto/s5p-sss.c:1213 s5p_hash_prepare_request() warn: variable dereferenced before check 'req' (see line 1208)

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/crypto/s5p-sss.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index 5d64c08b7f47..d7c8163e5068 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -1210,9 +1210,6 @@ static int s5p_hash_prepare_request(struct ahash_request *req, bool update)
 	int xmit_len, hash_later, nbytes;
 	int ret;
 
-	if (!req)
-		return 0;
-
 	if (update)
 		nbytes = req->nbytes;
 	else
-- 
2.7.4

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

* [PATCH 4/4] crypto: s5p-sss - Constify pointed data (arguments and local variables)
  2018-03-01 20:50 [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request Krzysztof Kozlowski
  2018-03-01 20:50 ` [PATCH 2/4] crypto: omap-sham - Fix misleading indentation Krzysztof Kozlowski
  2018-03-01 20:50 ` [PATCH 3/4] crypto: s5p-sss: Remove useless check for non-null request Krzysztof Kozlowski
@ 2018-03-01 20:50 ` Krzysztof Kozlowski
  2018-03-05  8:58   ` Tero Kristo
  2018-03-09 15:19 ` Herbert Xu
  4 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2018-03-01 20:50 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Krzysztof Kozlowski,
	Vladimir Zapolskiy, Kamil Konieczny, Tero Kristo, linux-crypto,
	linux-kernel, linux-samsung-soc

Improve the code (safety and readability) by indicating that data passed
through pointer is not modified.  This adds const keyword in many places,
most notably:
 - the driver data (pointer to struct samsung_aes_variant),
 - scatterlist addresses written as value to device registers,
 - key and IV arrays.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/crypto/s5p-sss.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index d7c8163e5068..bf7163042569 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -404,29 +404,31 @@ static const struct of_device_id s5p_sss_dt_match[] = {
 };
 MODULE_DEVICE_TABLE(of, s5p_sss_dt_match);
 
-static inline struct samsung_aes_variant *find_s5p_sss_version
-				   (struct platform_device *pdev)
+static inline const struct samsung_aes_variant *find_s5p_sss_version
+				   (const struct platform_device *pdev)
 {
 	if (IS_ENABLED(CONFIG_OF) && (pdev->dev.of_node)) {
 		const struct of_device_id *match;
 
 		match = of_match_node(s5p_sss_dt_match,
 					pdev->dev.of_node);
-		return (struct samsung_aes_variant *)match->data;
+		return (const struct samsung_aes_variant *)match->data;
 	}
-	return (struct samsung_aes_variant *)
+	return (const struct samsung_aes_variant *)
 			platform_get_device_id(pdev)->driver_data;
 }
 
 static struct s5p_aes_dev *s5p_dev;
 
-static void s5p_set_dma_indata(struct s5p_aes_dev *dev, struct scatterlist *sg)
+static void s5p_set_dma_indata(struct s5p_aes_dev *dev,
+			       const struct scatterlist *sg)
 {
 	SSS_WRITE(dev, FCBRDMAS, sg_dma_address(sg));
 	SSS_WRITE(dev, FCBRDMAL, sg_dma_len(sg));
 }
 
-static void s5p_set_dma_outdata(struct s5p_aes_dev *dev, struct scatterlist *sg)
+static void s5p_set_dma_outdata(struct s5p_aes_dev *dev,
+				const struct scatterlist *sg)
 {
 	SSS_WRITE(dev, FCBTDMAS, sg_dma_address(sg));
 	SSS_WRITE(dev, FCBTDMAL, sg_dma_len(sg));
@@ -619,7 +621,7 @@ static inline void s5p_hash_write(struct s5p_aes_dev *dd,
  * @sg:		scatterlist ready to DMA transmit
  */
 static void s5p_set_dma_hashdata(struct s5p_aes_dev *dev,
-				 struct scatterlist *sg)
+				 const struct scatterlist *sg)
 {
 	dev->hash_sg_cnt--;
 	SSS_WRITE(dev, FCHRDMAS, sg_dma_address(sg));
@@ -792,9 +794,9 @@ static void s5p_hash_read_msg(struct ahash_request *req)
  * @ctx:	request context
  */
 static void s5p_hash_write_ctx_iv(struct s5p_aes_dev *dd,
-				  struct s5p_hash_reqctx *ctx)
+				  const struct s5p_hash_reqctx *ctx)
 {
-	u32 *hash = (u32 *)ctx->digest;
+	const u32 *hash = (const u32 *)ctx->digest;
 	unsigned int i;
 
 	for (i = 0; i < ctx->nregs; i++)
@@ -818,7 +820,7 @@ static void s5p_hash_write_iv(struct ahash_request *req)
  */
 static void s5p_hash_copy_result(struct ahash_request *req)
 {
-	struct s5p_hash_reqctx *ctx = ahash_request_ctx(req);
+	const struct s5p_hash_reqctx *ctx = ahash_request_ctx(req);
 
 	if (!req->result)
 		return;
@@ -1290,7 +1292,7 @@ static int s5p_hash_prepare_request(struct ahash_request *req, bool update)
  */
 static void s5p_hash_update_dma_stop(struct s5p_aes_dev *dd)
 {
-	struct s5p_hash_reqctx *ctx = ahash_request_ctx(dd->hash_req);
+	const struct s5p_hash_reqctx *ctx = ahash_request_ctx(dd->hash_req);
 
 	dma_unmap_sg(dd->dev, ctx->sg, ctx->sg_len, DMA_TO_DEVICE);
 	clear_bit(HASH_FLAGS_DMA_ACTIVE, &dd->hash_flags);
@@ -1717,7 +1719,7 @@ static void s5p_hash_cra_exit(struct crypto_tfm *tfm)
  */
 static int s5p_hash_export(struct ahash_request *req, void *out)
 {
-	struct s5p_hash_reqctx *ctx = ahash_request_ctx(req);
+	const struct s5p_hash_reqctx *ctx = ahash_request_ctx(req);
 
 	memcpy(out, ctx, sizeof(*ctx) + ctx->bufcnt);
 
@@ -1831,7 +1833,8 @@ static struct ahash_alg algs_sha1_md5_sha256[] = {
 };
 
 static void s5p_set_aes(struct s5p_aes_dev *dev,
-			uint8_t *key, uint8_t *iv, unsigned int keylen)
+			const uint8_t *key, const uint8_t *iv,
+			unsigned int keylen)
 {
 	void __iomem *keystart;
 
@@ -2150,7 +2153,7 @@ static int s5p_aes_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	int i, j, err = -ENODEV;
-	struct samsung_aes_variant *variant;
+	const struct samsung_aes_variant *variant;
 	struct s5p_aes_dev *pdata;
 	struct resource *res;
 	unsigned int hash_i;
-- 
2.7.4

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

* Re: [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request
  2018-03-01 20:50 [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request Krzysztof Kozlowski
@ 2018-03-05  8:58   ` Tero Kristo
  2018-03-01 20:50 ` [PATCH 3/4] crypto: s5p-sss: Remove useless check for non-null request Krzysztof Kozlowski
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Tero Kristo @ 2018-03-05  8:58 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Herbert Xu, David S. Miller,
	Vladimir Zapolskiy, Kamil Konieczny, linux-crypto, linux-kernel,
	linux-samsung-soc

On 01/03/18 22:50, Krzysztof Kozlowski wrote:
> ahash_request 'req' argument passed by the caller
> omap_sham_handle_queue() cannot be NULL here because it is obtained from
> non-NULL pointer via container_of().
> 
> This fixes smatch warning:
>      drivers/crypto/omap-sham.c:812 omap_sham_prepare_request() warn: variable dereferenced before check 'req' (see line 805)
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Acked-by: Tero Kristo <t-kristo@ti.com>

> ---
>   drivers/crypto/omap-sham.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
> index 86b89ace836f..7650b1b449bb 100644
> --- a/drivers/crypto/omap-sham.c
> +++ b/drivers/crypto/omap-sham.c
> @@ -809,9 +809,6 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update)
>   	bool final = rctx->flags & BIT(FLAGS_FINUP);
>   	int xmit_len, hash_later;
>   
> -	if (!req)
> -		return 0;
> -
>   	bs = get_block_size(rctx);
>   
>   	if (update)
> 

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request
@ 2018-03-05  8:58   ` Tero Kristo
  0 siblings, 0 replies; 9+ messages in thread
From: Tero Kristo @ 2018-03-05  8:58 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Herbert Xu, David S. Miller,
	Vladimir Zapolskiy, Kamil Konieczny, linux-crypto, linux-kernel,
	linux-samsung-soc

On 01/03/18 22:50, Krzysztof Kozlowski wrote:
> ahash_request 'req' argument passed by the caller
> omap_sham_handle_queue() cannot be NULL here because it is obtained from
> non-NULL pointer via container_of().
> 
> This fixes smatch warning:
>      drivers/crypto/omap-sham.c:812 omap_sham_prepare_request() warn: variable dereferenced before check 'req' (see line 805)
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Acked-by: Tero Kristo <t-kristo@ti.com>

> ---
>   drivers/crypto/omap-sham.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
> index 86b89ace836f..7650b1b449bb 100644
> --- a/drivers/crypto/omap-sham.c
> +++ b/drivers/crypto/omap-sham.c
> @@ -809,9 +809,6 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update)
>   	bool final = rctx->flags & BIT(FLAGS_FINUP);
>   	int xmit_len, hash_later;
>   
> -	if (!req)
> -		return 0;
> -
>   	bs = get_block_size(rctx);
>   
>   	if (update)
> 

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH 2/4] crypto: omap-sham - Fix misleading indentation
  2018-03-01 20:50 ` [PATCH 2/4] crypto: omap-sham - Fix misleading indentation Krzysztof Kozlowski
@ 2018-03-05  8:59     ` Tero Kristo
  0 siblings, 0 replies; 9+ messages in thread
From: Tero Kristo @ 2018-03-05  8:59 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Herbert Xu, David S. Miller,
	Vladimir Zapolskiy, Kamil Konieczny, linux-crypto, linux-kernel,
	linux-samsung-soc

On 01/03/18 22:50, Krzysztof Kozlowski wrote:
> Commit 8043bb1ae03c ("crypto: omap-sham - convert driver logic to use
> sgs for data xmit") removed the if() clause leaving the statement as is.
> The intention was in that case to finish the request always so the goto
> instruction seems sensible.
> 
> Remove the indentation to fix Smatch warning:
>      drivers/crypto/omap-sham.c:1761 omap_sham_done_task() warn: inconsistent indenting
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Acked-by: Tero Kristo <t-kristo@ti.com>

> ---
>   drivers/crypto/omap-sham.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
> index 7650b1b449bb..6cb6ab6f52c0 100644
> --- a/drivers/crypto/omap-sham.c
> +++ b/drivers/crypto/omap-sham.c
> @@ -1758,7 +1758,7 @@ static void omap_sham_done_task(unsigned long data)
>   		if (test_and_clear_bit(FLAGS_OUTPUT_READY, &dd->flags)) {
>   			/* hash or semi-hash ready */
>   			clear_bit(FLAGS_DMA_READY, &dd->flags);
> -				goto finish;
> +			goto finish;
>   		}
>   	}
>   
> 

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH 2/4] crypto: omap-sham - Fix misleading indentation
@ 2018-03-05  8:59     ` Tero Kristo
  0 siblings, 0 replies; 9+ messages in thread
From: Tero Kristo @ 2018-03-05  8:59 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Herbert Xu, David S. Miller,
	Vladimir Zapolskiy, Kamil Konieczny, linux-crypto, linux-kernel,
	linux-samsung-soc

On 01/03/18 22:50, Krzysztof Kozlowski wrote:
> Commit 8043bb1ae03c ("crypto: omap-sham - convert driver logic to use
> sgs for data xmit") removed the if() clause leaving the statement as is.
> The intention was in that case to finish the request always so the goto
> instruction seems sensible.
> 
> Remove the indentation to fix Smatch warning:
>      drivers/crypto/omap-sham.c:1761 omap_sham_done_task() warn: inconsistent indenting
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Acked-by: Tero Kristo <t-kristo@ti.com>

> ---
>   drivers/crypto/omap-sham.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
> index 7650b1b449bb..6cb6ab6f52c0 100644
> --- a/drivers/crypto/omap-sham.c
> +++ b/drivers/crypto/omap-sham.c
> @@ -1758,7 +1758,7 @@ static void omap_sham_done_task(unsigned long data)
>   		if (test_and_clear_bit(FLAGS_OUTPUT_READY, &dd->flags)) {
>   			/* hash or semi-hash ready */
>   			clear_bit(FLAGS_DMA_READY, &dd->flags);
> -				goto finish;
> +			goto finish;
>   		}
>   	}
>   
> 

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request
  2018-03-01 20:50 [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  2018-03-05  8:58   ` Tero Kristo
@ 2018-03-09 15:19 ` Herbert Xu
  4 siblings, 0 replies; 9+ messages in thread
From: Herbert Xu @ 2018-03-09 15:19 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: David S. Miller, Vladimir Zapolskiy, Kamil Konieczny,
	Tero Kristo, linux-crypto, linux-kernel, linux-samsung-soc

On Thu, Mar 01, 2018 at 09:50:10PM +0100, Krzysztof Kozlowski wrote:
> ahash_request 'req' argument passed by the caller
> omap_sham_handle_queue() cannot be NULL here because it is obtained from
> non-NULL pointer via container_of().
> 
> This fixes smatch warning:
>     drivers/crypto/omap-sham.c:812 omap_sham_prepare_request() warn: variable dereferenced before check 'req' (see line 805)
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

All 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] 9+ messages in thread

end of thread, other threads:[~2018-03-09 15:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01 20:50 [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request Krzysztof Kozlowski
2018-03-01 20:50 ` [PATCH 2/4] crypto: omap-sham - Fix misleading indentation Krzysztof Kozlowski
2018-03-05  8:59   ` Tero Kristo
2018-03-05  8:59     ` Tero Kristo
2018-03-01 20:50 ` [PATCH 3/4] crypto: s5p-sss: Remove useless check for non-null request Krzysztof Kozlowski
2018-03-01 20:50 ` [PATCH 4/4] crypto: s5p-sss - Constify pointed data (arguments and local variables) Krzysztof Kozlowski
2018-03-05  8:58 ` [PATCH 1/4] crypto: omap-sham: Remove useless check for non-null request Tero Kristo
2018-03-05  8:58   ` Tero Kristo
2018-03-09 15:19 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.