Skip to content

Commit

Permalink
crypto: omap-sham - Check for return value from pm_runtime_get_sync
Browse files Browse the repository at this point in the history
Function pm_runtime_get_sync could fail and we need to check return
value to prevent kernel crash.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Pali Rohár authored and Herbert Xu committed May 15, 2015
1 parent ca7fc7e commit 604c310
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions drivers/crypto/omap-sham.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,13 @@ static void omap_sham_copy_ready_hash(struct ahash_request *req)

static int omap_sham_hw_init(struct omap_sham_dev *dd)
{
pm_runtime_get_sync(dd->dev);
int err;

err = pm_runtime_get_sync(dd->dev);
if (err < 0) {
dev_err(dd->dev, "failed to get sync: %d\n", err);
return err;
}

if (!test_bit(FLAGS_INIT, &dd->flags)) {
set_bit(FLAGS_INIT, &dd->flags);
Expand Down Expand Up @@ -1947,7 +1953,13 @@ static int omap_sham_probe(struct platform_device *pdev)

pm_runtime_enable(dev);
pm_runtime_irq_safe(dev);
pm_runtime_get_sync(dev);

err = pm_runtime_get_sync(dev);
if (err < 0) {
dev_err(dev, "failed to get sync: %d\n", err);
goto err_pm;
}

rev = omap_sham_read(dd, SHA_REG_REV(dd));
pm_runtime_put_sync(&pdev->dev);

Expand Down Expand Up @@ -1977,6 +1989,7 @@ static int omap_sham_probe(struct platform_device *pdev)
for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--)
crypto_unregister_ahash(
&dd->pdata->algs_info[i].algs_list[j]);
err_pm:
pm_runtime_disable(dev);
if (dd->dma_lch)
dma_release_channel(dd->dma_lch);
Expand Down Expand Up @@ -2019,7 +2032,11 @@ static int omap_sham_suspend(struct device *dev)

static int omap_sham_resume(struct device *dev)
{
pm_runtime_get_sync(dev);
int err = pm_runtime_get_sync(dev);
if (err < 0) {
dev_err(dev, "failed to get sync: %d\n", err);
return err;
}
return 0;
}
#endif
Expand Down

0 comments on commit 604c310

Please sign in to comment.