Commit 2d55807b authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Herbert Xu

crypto: picoxcell - Fix error handling in spacc_probe()

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: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: default avatarJamie Iles <jamie@jamieiles.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent fb87127b
...@@ -1618,7 +1618,7 @@ MODULE_DEVICE_TABLE(of, spacc_of_id_table); ...@@ -1618,7 +1618,7 @@ MODULE_DEVICE_TABLE(of, spacc_of_id_table);
static int spacc_probe(struct platform_device *pdev) static int spacc_probe(struct platform_device *pdev)
{ {
int i, err, ret = -EINVAL; int i, err, ret;
struct resource *mem, *irq; struct resource *mem, *irq;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct spacc_engine *engine = devm_kzalloc(&pdev->dev, sizeof(*engine), struct spacc_engine *engine = devm_kzalloc(&pdev->dev, sizeof(*engine),
...@@ -1679,22 +1679,18 @@ static int spacc_probe(struct platform_device *pdev) ...@@ -1679,22 +1679,18 @@ static int spacc_probe(struct platform_device *pdev)
engine->clk = clk_get(&pdev->dev, "ref"); engine->clk = clk_get(&pdev->dev, "ref");
if (IS_ERR(engine->clk)) { if (IS_ERR(engine->clk)) {
dev_info(&pdev->dev, "clk unavailable\n"); dev_info(&pdev->dev, "clk unavailable\n");
device_remove_file(&pdev->dev, &dev_attr_stat_irq_thresh);
return PTR_ERR(engine->clk); return PTR_ERR(engine->clk);
} }
if (clk_prepare_enable(engine->clk)) { if (clk_prepare_enable(engine->clk)) {
dev_info(&pdev->dev, "unable to prepare/enable clk\n"); dev_info(&pdev->dev, "unable to prepare/enable clk\n");
clk_put(engine->clk); ret = -EIO;
return -EIO; goto err_clk_put;
} }
err = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh); ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh);
if (err) { if (ret)
clk_disable_unprepare(engine->clk); goto err_clk_disable;
clk_put(engine->clk);
return err;
}
/* /*
...@@ -1725,6 +1721,7 @@ static int spacc_probe(struct platform_device *pdev) ...@@ -1725,6 +1721,7 @@ static int spacc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, engine); platform_set_drvdata(pdev, engine);
ret = -EINVAL;
INIT_LIST_HEAD(&engine->registered_algs); INIT_LIST_HEAD(&engine->registered_algs);
for (i = 0; i < engine->num_algs; ++i) { for (i = 0; i < engine->num_algs; ++i) {
engine->algs[i].engine = engine; engine->algs[i].engine = engine;
...@@ -1759,6 +1756,16 @@ static int spacc_probe(struct platform_device *pdev) ...@@ -1759,6 +1756,16 @@ static int spacc_probe(struct platform_device *pdev)
engine->aeads[i].alg.base.cra_name); 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; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment