Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: APEI: EINJ: Fix resource leak by remove callback in .exit.text

The .remove() callback is also used during error handling in
faux_probe(). As einj_remove() was marked with __exit it's not linked
into the kernel if the driver is built-in, potentially resulting in
resource leaks.

Also remove the comment justifying the __exit annotation which doesn't
apply any more since the driver was converted to the faux device
interface.

Fixes: 6cb9441bfe8d ("ACPI: APEI: EINJ: Transition to the faux device interface")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Cc: 6.16+ <stable@vger.kernel.org> # 6.16+
Link: https://patch.msgid.link/20250814051157.35867-2-u.kleine-koenig@baylibre.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Uwe Kleine-König and committed by
Rafael J. Wysocki
b21d1fbb 7459e87a

+3 -9
+3 -9
drivers/acpi/apei/einj-core.c
··· 1094 1094 return rc; 1095 1095 } 1096 1096 1097 - static void __exit einj_remove(struct faux_device *fdev) 1097 + static void einj_remove(struct faux_device *fdev) 1098 1098 { 1099 1099 struct apei_exec_context ctx; 1100 1100 ··· 1117 1117 } 1118 1118 1119 1119 static struct faux_device *einj_dev; 1120 - /* 1121 - * einj_remove() lives in .exit.text. For drivers registered via 1122 - * platform_driver_probe() this is ok because they cannot get unbound at 1123 - * runtime. So mark the driver struct with __refdata to prevent modpost 1124 - * triggering a section mismatch warning. 1125 - */ 1126 - static struct faux_device_ops einj_device_ops __refdata = { 1120 + static struct faux_device_ops einj_device_ops = { 1127 1121 .probe = einj_probe, 1128 - .remove = __exit_p(einj_remove), 1122 + .remove = einj_remove, 1129 1123 }; 1130 1124 1131 1125 static int __init einj_init(void)