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

Commit 734ff111 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Greg Kroah-Hartman
Browse files

ARM: mmp: Fix failure to remove sram device



[ Upstream commit 4036b29a146b2749af3bb213b003eb69f3e5ecc4 ]

Make sure in .probe() to set driver data before the function is left to
make it possible in .remove() to undo the actions done.

This fixes a potential memory leak and stops returning an error code in
.remove() that is ignored by the driver core anyhow.

Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent d3379b71
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ static int sram_probe(struct platform_device *pdev)
	if (!info)
		return -ENOMEM;

	platform_set_drvdata(pdev, info);

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "no memory resource defined\n");
@@ -110,8 +112,6 @@ static int sram_probe(struct platform_device *pdev)
	list_add(&info->node, &sram_bank_list);
	mutex_unlock(&sram_lock);

	platform_set_drvdata(pdev, info);

	dev_info(&pdev->dev, "initialized\n");
	return 0;

@@ -130,9 +130,8 @@ static int sram_remove(struct platform_device *pdev)
	struct sram_bank_info *info;

	info = platform_get_drvdata(pdev);
	if (info == NULL)
		return -ENODEV;

	if (info->sram_size) {
		mutex_lock(&sram_lock);
		list_del(&info->node);
		mutex_unlock(&sram_lock);
@@ -140,7 +139,10 @@ static int sram_remove(struct platform_device *pdev)
		gen_pool_destroy(info->gpool);
		iounmap(info->sram_virt);
		kfree(info->pool_name);
	}

	kfree(info);

	return 0;
}