Skip to content

Commit 61dc0a4

Browse files
nmenonherbertx
authored andcommitted
hwrng: omap - Fix assumption that runtime_get_sync will always succeed
pm_runtime_get_sync does return a error value that must be checked for error conditions, else, due to various reasons, the device maynot be enabled and the system will crash due to lack of clock to the hardware module. Before: 12.562784] [00000000] *pgd=fe193835 12.562792] Internal error: : 1406 [tobetter#1] SMP ARM [...] 12.562864] CPU: 1 PID: 241 Comm: modprobe Not tainted 4.7.0-rc4-next-20160624 tobetter#2 12.562867] Hardware name: Generic DRA74X (Flattened Device Tree) 12.562872] task: ed51f140 ti: ed44c000 task.ti: ed44c000 12.562886] PC is at omap4_rng_init+0x20/0x84 [omap_rng] 12.562899] LR is at set_current_rng+0xc0/0x154 [rng_core] [...] After the proper checks: [ 94.366705] omap_rng 48090000.rng: _od_fail_runtime_resume: FIXME: missing hwmod/omap_dev info [ 94.375767] omap_rng 48090000.rng: Failed to runtime_get device -19 [ 94.382351] omap_rng 48090000.rng: initialization failed. Fixes: 665d92f ("hwrng: OMAP: convert to use runtime PM") Cc: Paul Walmsley <[email protected]> Signed-off-by: Nishanth Menon <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 90ab5a8 commit 61dc0a4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/char/hw_random/omap-rng.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,12 @@ static int omap_rng_probe(struct platform_device *pdev)
384384
}
385385

386386
pm_runtime_enable(&pdev->dev);
387-
pm_runtime_get_sync(&pdev->dev);
387+
ret = pm_runtime_get_sync(&pdev->dev);
388+
if (ret) {
389+
dev_err(&pdev->dev, "Failed to runtime_get device: %d\n", ret);
390+
pm_runtime_put_noidle(&pdev->dev);
391+
goto err_ioremap;
392+
}
388393

389394
ret = (dev->of_node) ? of_get_omap_rng_device_details(priv, pdev) :
390395
get_omap_rng_device_details(priv);
@@ -435,8 +440,15 @@ static int __maybe_unused omap_rng_suspend(struct device *dev)
435440
static int __maybe_unused omap_rng_resume(struct device *dev)
436441
{
437442
struct omap_rng_dev *priv = dev_get_drvdata(dev);
443+
int ret;
444+
445+
ret = pm_runtime_get_sync(dev);
446+
if (ret) {
447+
dev_err(dev, "Failed to runtime_get device: %d\n", ret);
448+
pm_runtime_put_noidle(dev);
449+
return ret;
450+
}
438451

439-
pm_runtime_get_sync(dev);
440452
priv->pdata->init(priv);
441453

442454
return 0;

0 commit comments

Comments
 (0)