Skip to content

Commit f2f212f

Browse files
Uwe Kleine-Königrafaeljw
authored andcommitted
ACPI: APEI: GHES: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Instead of returning an error code, emit a better error message than the core. Apart from the improved error message this patch has no effects for the driver. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent d206a76 commit f2f212f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/acpi/apei/ghes.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ static int ghes_probe(struct platform_device *ghes_dev)
14551455
return rc;
14561456
}
14571457

1458-
static int ghes_remove(struct platform_device *ghes_dev)
1458+
static void ghes_remove(struct platform_device *ghes_dev)
14591459
{
14601460
int rc;
14611461
struct ghes *ghes;
@@ -1492,8 +1492,15 @@ static int ghes_remove(struct platform_device *ghes_dev)
14921492
break;
14931493
case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED:
14941494
rc = apei_sdei_unregister_ghes(ghes);
1495-
if (rc)
1496-
return rc;
1495+
if (rc) {
1496+
/*
1497+
* Returning early results in a resource leak, but we're
1498+
* only here if stopping the hardware failed.
1499+
*/
1500+
dev_err(&ghes_dev->dev, "Failed to unregister ghes (%pe)\n",
1501+
ERR_PTR(rc));
1502+
return;
1503+
}
14971504
break;
14981505
default:
14991506
BUG();
@@ -1507,16 +1514,14 @@ static int ghes_remove(struct platform_device *ghes_dev)
15071514
mutex_unlock(&ghes_devs_mutex);
15081515

15091516
kfree(ghes);
1510-
1511-
return 0;
15121517
}
15131518

15141519
static struct platform_driver ghes_platform_driver = {
15151520
.driver = {
15161521
.name = "GHES",
15171522
},
15181523
.probe = ghes_probe,
1519-
.remove = ghes_remove,
1524+
.remove_new = ghes_remove,
15201525
};
15211526

15221527
void __init acpi_ghes_init(void)

0 commit comments

Comments
 (0)