Skip to contentSkip to conversation

crypto: sa2ul - Hide pointer and fix -Wpointer-to-int-cast in dev_dbg()

PATCH In review Krzysztof Kozlowski 2 participants 7 messages Aug 26, 2020 – Mar 1, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 crypto: sa2ul - Hide pointer and fix -Wpointer-to-int-cast in dev_dbg()

Pointers should not be printed because they might leak important information about address space layout. Use %p to hash the value. This also fixes compilation warnings on 32-bit architecture:

drivers/crypto/sa2ul.c:1486:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

---
 drivers/crypto/sa2ul.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/sa2ul.c +2 -2
index 5bc099052bd2..4a950437bf44 100644
@@ -1482,8 +1482,8 @@ static int sa_sha_init(struct ahash_request *req)
 	struct sa_sha_req_ctx *rctx = ahash_request_ctx(req);
 	struct sa_tfm_ctx *ctx = crypto_ahash_ctx(tfm);
 
-	dev_dbg(sa_k3_dev, "init: digest size: %d, rctx=%llx\n",
-		crypto_ahash_digestsize(tfm), (u64)rctx);
+	dev_dbg(sa_k3_dev, "init: digest size: %d, rctx=%p\n",
+		crypto_ahash_digestsize(tfm), rctx);
 
 	ahash_request_set_tfm(&rctx->fallback_req, ctx->fallback.ahash);
 	rctx->fallback_req.base.flags =
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/3 crypto: sa2ul - Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---
 drivers/crypto/sa2ul.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/crypto/sa2ul.c +7 -11
index 4a950437bf44..5a11c2fb7a3a 100644
@@ -2243,25 +2243,21 @@ static int sa_dma_init(struct sa_crypto_data *dd)
 		return ret;
 
 	dd->dma_rx1 = dma_request_chan(dd->dev, "rx1");
-	if (IS_ERR(dd->dma_rx1)) {
-		if (PTR_ERR(dd->dma_rx1) != -EPROBE_DEFER)
-			dev_err(dd->dev, "Unable to request rx1 DMA channel\n");
-		return PTR_ERR(dd->dma_rx1);
-	}
+	if (IS_ERR(dd->dma_rx1))
+		return dev_err_probe(dd->dev, PTR_ERR(dd->dma_rx1),
+				     "Unable to request rx1 DMA channel\n");
 
 	dd->dma_rx2 = dma_request_chan(dd->dev, "rx2");
 	if (IS_ERR(dd->dma_rx2)) {
 		dma_release_channel(dd->dma_rx1);
-		if (PTR_ERR(dd->dma_rx2) != -EPROBE_DEFER)
-			dev_err(dd->dev, "Unable to request rx2 DMA channel\n");
-		return PTR_ERR(dd->dma_rx2);
+		return dev_err_probe(dd->dev, PTR_ERR(dd->dma_rx2),
+				     "Unable to request rx2 DMA channel\n");
 	}
 
 	dd->dma_tx = dma_request_chan(dd->dev, "tx");
 	if (IS_ERR(dd->dma_tx)) {
-		if (PTR_ERR(dd->dma_tx) != -EPROBE_DEFER)
-			dev_err(dd->dev, "Unable to request tx DMA channel\n");
-		ret = PTR_ERR(dd->dma_tx);
+		ret = dev_err_probe(dd->dev, PTR_ERR(dd->dma_tx),
+				    "Unable to request tx DMA channel\n");
 		goto err_dma_tx;
 	}
 
Signature · 1 line
2.17.1
#2 lore raw

PATCH 3/3 crypto: ccree - Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---
 drivers/crypto/ccree/cc_driver.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/crypto/ccree/cc_driver.c +2 -5
index 2d50991b9a17..6f519d3e896c 100644
@@ -300,11 +300,8 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	new_drvdata->plat_dev = plat_dev;
 
 	clk = devm_clk_get_optional(dev, NULL);
-	if (IS_ERR(clk)) {
-		if (PTR_ERR(clk) != -EPROBE_DEFER)
-			dev_err(dev, "Error getting clock: %pe\n", clk);
-		return PTR_ERR(clk);
-	}
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk), "Error getting clock\n");
 	new_drvdata->clk = clk;
 
 	new_drvdata->coherent = of_dma_is_coherent(np);
Signature · 1 line
2.17.1
maintainer
#3 lore raw
In reply to Krzysztof Kozlowski
Quoted 10 lines · Krzysztof Kozlowski

Pointers should not be printed because they might leak important information about address space layout. Use %p to hash the value. This also fixes compilation warnings on 32-bit architecture:

drivers/crypto/sa2ul.c:1486:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

---
 drivers/crypto/sa2ul.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

All 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
#4 lore raw
Quoted 6 lines · Herbert Xu
Quoted 4 lines · Krzysztof Kozlowski

Pointers should not be printed because they might leak important information about address space layout. Use %p to hash the value. This also fixes compilation warnings on 32-bit architecture:

Quoted 8 lines
Quoted 6 lines

drivers/crypto/sa2ul.c:1486:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

---
 drivers/crypto/sa2ul.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

All applied. Thanks.

Hi Herbert,

I think this patch was lost, although you replied that the entire set is applied.

Can you pick it up?

Best regards,
Krzysztof

maintainer
#5 lore raw
Quoted 5 lines · Krzysztof Kozlowski

I think this patch was lost, although you replied that the entire set is applied.

Can you pick it up?

I think it was not applicable because the following had already been applied:

commit ea066b7a3ddf1e4e5ae749495f0adf12766188b4

Author: YueHaibing <[email protected]>
Date:   Tue Aug 18 22:00:01 2020 +0800

crypto: sa2ul - Fix pointer-to-int-cast warning

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
#6 lore raw
Quoted 8 lines · Herbert Xu
Quoted 5 lines · Krzysztof Kozlowski

I think this patch was lost, although you replied that the entire set is applied.

Can you pick it up?

Quoted 8 lines

I think it was not applicable because the following had already been applied:

commit ea066b7a3ddf1e4e5ae749495f0adf12766188b4

Author: YueHaibing <[email protected]>
Date:   Tue Aug 18 22:00:01 2020 +0800

crypto: sa2ul - Fix pointer-to-int-cast warning

Yes, you're right. Sorry for the noise.

Best regards,
Krzysztof