* [PATCH] crypto: picoxcell - Fix error handling in spacc_probe()
@ 2018-01-19 21:53 Alexey Khoroshilov
2018-01-24 13:08 ` Jamie Iles
2018-01-26 15:46 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Khoroshilov @ 2018-01-19 21:53 UTC (permalink / raw)
To: Jamie Iles, Javier Martinez Canillas
Cc: Alexey Khoroshilov, Herbert Xu, David S. Miller,
linux-arm-kernel, linux-crypto, linux-kernel, ldv-project
If clk_get() fails, device_remove_file() looks inappropriate.
The error path, where all crypto_register fail, misses resource
deallocations.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/crypto/picoxcell_crypto.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c
index 5a6dc53b2b9d..4ef52c9d72fc 100644
--- a/drivers/crypto/picoxcell_crypto.c
+++ b/drivers/crypto/picoxcell_crypto.c
@@ -1618,7 +1618,7 @@ MODULE_DEVICE_TABLE(of, spacc_of_id_table);
static int spacc_probe(struct platform_device *pdev)
{
- int i, err, ret = -EINVAL;
+ int i, err, ret;
struct resource *mem, *irq;
struct device_node *np = pdev->dev.of_node;
struct spacc_engine *engine = devm_kzalloc(&pdev->dev, sizeof(*engine),
@@ -1679,22 +1679,18 @@ static int spacc_probe(struct platform_device *pdev)
engine->clk = clk_get(&pdev->dev, "ref");
if (IS_ERR(engine->clk)) {
dev_info(&pdev->dev, "clk unavailable\n");
- device_remove_file(&pdev->dev, &dev_attr_stat_irq_thresh);
return PTR_ERR(engine->clk);
}
if (clk_prepare_enable(engine->clk)) {
dev_info(&pdev->dev, "unable to prepare/enable clk\n");
- clk_put(engine->clk);
- return -EIO;
+ ret = -EIO;
+ goto err_clk_put;
}
- err = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh);
- if (err) {
- clk_disable_unprepare(engine->clk);
- clk_put(engine->clk);
- return err;
- }
+ ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh);
+ if (ret)
+ goto err_clk_disable;
/*
@@ -1725,6 +1721,7 @@ static int spacc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, engine);
+ ret = -EINVAL;
INIT_LIST_HEAD(&engine->registered_algs);
for (i = 0; i < engine->num_algs; ++i) {
engine->algs[i].engine = engine;
@@ -1759,6 +1756,16 @@ static int spacc_probe(struct platform_device *pdev)
engine->aeads[i].alg.base.cra_name);
}
+ if (!ret)
+ return 0;
+
+ del_timer_sync(&engine->packet_timeout);
+ device_remove_file(&pdev->dev, &dev_attr_stat_irq_thresh);
+err_clk_disable:
+ clk_disable_unprepare(engine->clk);
+err_clk_put:
+ clk_put(engine->clk);
+
return ret;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: picoxcell - Fix error handling in spacc_probe()
2018-01-19 21:53 [PATCH] crypto: picoxcell - Fix error handling in spacc_probe() Alexey Khoroshilov
@ 2018-01-24 13:08 ` Jamie Iles
2018-01-26 15:46 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Jamie Iles @ 2018-01-24 13:08 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Jamie Iles, Javier Martinez Canillas, Herbert Xu,
David S. Miller, linux-arm-kernel, linux-crypto, linux-kernel,
ldv-project
Thanks Alexey!
On Sat, Jan 20, 2018 at 12:53:15AM +0300, Alexey Khoroshilov wrote:
> If clk_get() fails, device_remove_file() looks inappropriate.
>
> The error path, where all crypto_register fail, misses resource
> deallocations.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: Jamie Iles <jamie@jamieiles.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: picoxcell - Fix error handling in spacc_probe()
2018-01-19 21:53 [PATCH] crypto: picoxcell - Fix error handling in spacc_probe() Alexey Khoroshilov
2018-01-24 13:08 ` Jamie Iles
@ 2018-01-26 15:46 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2018-01-26 15:46 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Jamie Iles, Javier Martinez Canillas, David S. Miller,
linux-arm-kernel, linux-crypto, linux-kernel, ldv-project
On Sat, Jan 20, 2018 at 12:53:15AM +0300, Alexey Khoroshilov wrote:
> If clk_get() fails, device_remove_file() looks inappropriate.
>
> The error path, where all crypto_register fail, misses resource
> deallocations.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
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:[~2018-01-26 16:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 21:53 [PATCH] crypto: picoxcell - Fix error handling in spacc_probe() Alexey Khoroshilov
2018-01-24 13:08 ` Jamie Iles
2018-01-26 15:46 ` 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).