Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5b9653d authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman
Browse files

misc: sram: enable clock before registering regions



Make sure to enable the clock before registering regions and exporting
partitions to user space at which point we must be prepared for I/O.

Fixes: ee895ccd ("misc: sram: fix enabled clock leak on error path")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Reviewed-by: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f294d009
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -391,23 +391,23 @@ static int sram_probe(struct platform_device *pdev)
	if (IS_ERR(sram->pool))
		return PTR_ERR(sram->pool);

	ret = sram_reserve_regions(sram, res);
	if (ret)
		return ret;

	sram->clk = devm_clk_get(sram->dev, NULL);
	if (IS_ERR(sram->clk))
		sram->clk = NULL;
	else
		clk_prepare_enable(sram->clk);

	ret = sram_reserve_regions(sram, res);
	if (ret)
		goto err_disable_clk;

	platform_set_drvdata(pdev, sram);

	init_func = of_device_get_match_data(&pdev->dev);
	if (init_func) {
		ret = init_func();
		if (ret)
			goto err_disable_clk;
			goto err_free_partitions;
	}

	dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n",
@@ -415,10 +415,11 @@ static int sram_probe(struct platform_device *pdev)

	return 0;

err_free_partitions:
	sram_free_partitions(sram);
err_disable_clk:
	if (sram->clk)
		clk_disable_unprepare(sram->clk);
	sram_free_partitions(sram);

	return ret;
}