[PATCH] hwmon: (ibmaem) clean up sensors if version sysfs file fails
From: Pengpeng Hou
Date: Mon Jun 15 2026 - 02:47:20 EST
aem_register_sensors() creates the dynamic sensor files and the name
sysfs file before creating the version file.
Errors from the dynamic sensor files and from the name file already jump
to aem_remove_sensors(), but an error from creating the version file is
returned directly. That leaves the earlier sysfs files published even
though the AEM instance probe fails and the backing state is torn down.
Route the version-file failure through the same cleanup path as the
earlier sysfs creation failures.
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
drivers/hwmon/ibmaem.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index 0a9c3a29e6f2..305c41dd15bb 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -945,6 +945,9 @@ static int aem_register_sensors(struct aem_data *data,
if (err)
goto error;
err = device_create_file(dev, &sensor_dev_attr_version.dev_attr);
+ if (err)
+ goto error;
+
return err;
error:
--
2.50.1 (Apple Git-155)