Skip to content

Commit 63627ca

Browse files
Gavin Shanwilldeacon
authored andcommitted
firmware: arm_sdei: Unregister driver on error in sdei_init()
The SDEI platform device is created from device-tree node or ACPI (SDEI) table. For the later case, the platform device is created explicitly by this module. It'd better to unregister the driver on failure to create the device to keep the symmetry. The driver, owned by this module, isn't needed if the device isn't existing. Besides, the errno (@ret) should be updated accordingly in this case. Signed-off-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: James Morse <james.morse@arm.com> Link: https://lore.kernel.org/r/20200922130423.10173-6-gshan@redhat.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 10fd7c4 commit 63627ca

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/firmware/arm_sdei.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,9 +1090,12 @@ static int __init sdei_init(void)
10901090

10911091
pdev = platform_device_register_simple(sdei_driver.driver.name,
10921092
0, NULL, 0);
1093-
if (IS_ERR(pdev))
1094-
pr_info("Failed to register ACPI:SDEI platform device %ld\n",
1095-
PTR_ERR(pdev));
1093+
if (IS_ERR(pdev)) {
1094+
ret = PTR_ERR(pdev);
1095+
platform_driver_unregister(&sdei_driver);
1096+
pr_info("Failed to register ACPI:SDEI platform device %d\n",
1097+
ret);
1098+
}
10961099

10971100
return ret;
10981101
}

0 commit comments

Comments
 (0)