Skip to content

Commit d642ef7

Browse files
Uwe Kleine-Königbp3tk0v
authored andcommitted
virt: sev-guest: 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(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Link: https://lore.kernel.org/r/52826a50250304ab0af14c594009f7b901c2cd31.1703596577.git.u.kleine-koenig@pengutronix.de
1 parent 30579c8 commit d642ef7

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/virt/coco/sev-guest/sev-guest.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ static int __init sev_guest_probe(struct platform_device *pdev)
994994
return ret;
995995
}
996996

997-
static int __exit sev_guest_remove(struct platform_device *pdev)
997+
static void __exit sev_guest_remove(struct platform_device *pdev)
998998
{
999999
struct snp_guest_dev *snp_dev = platform_get_drvdata(pdev);
10001000

@@ -1003,8 +1003,6 @@ static int __exit sev_guest_remove(struct platform_device *pdev)
10031003
free_shared_pages(snp_dev->request, sizeof(struct snp_guest_msg));
10041004
deinit_crypto(snp_dev->crypto);
10051005
misc_deregister(&snp_dev->misc);
1006-
1007-
return 0;
10081006
}
10091007

10101008
/*
@@ -1013,7 +1011,7 @@ static int __exit sev_guest_remove(struct platform_device *pdev)
10131011
* with the SEV-SNP support, it is named "sev-guest".
10141012
*/
10151013
static struct platform_driver sev_guest_driver = {
1016-
.remove = __exit_p(sev_guest_remove),
1014+
.remove_new = __exit_p(sev_guest_remove),
10171015
.driver = {
10181016
.name = "sev-guest",
10191017
},

0 commit comments

Comments
 (0)