Commit fba2f22
platform/x86: lenovo-wmi-other: Balance IDA id allocation and free
Currently, the IDA id is only freed on wmi-other device removal or
failure to create firmware-attributes device, kset, or attributes. It
leaks IDA ids if the wmi-other device is bound multiple times, as the
unbind callback never frees the previously allocated IDA id.
Additionally, if the wmi-other device has failed to create a
firmware-attributes device before it gets removed, the wmi-device
removal callback double frees the same IDA id.
These bugs were found by sashiko.dev [1].
Fix them by moving ida_free() into lwmi_om_fw_attr_remove() so it is
balanced with ida_alloc() in lwmi_om_fw_attr_add(). With them fixed,
properly set and utilize the validity of priv->ida_id to balance
firmware-attributes registration and removal, without relying on
propagating the registration error to the component framework, which is
more reliable and aligns with the hwmon device registration and removal
sequences.
No functional change intended.
Fixes: edc4b18 ("platform/x86: Add Lenovo Other Mode WMI Driver")
Cc: stable@vger.kernel.org
Link: https://sashiko.dev/#/patchset/20260331181208.421552-1-derekjohn.clark%40gmail.com [1]
Signed-off-by: Rong Zhang <i@rong.moe>1 parent bc705a5 commit fba2f22
1 file changed
Lines changed: 20 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
957 | 957 | | |
958 | 958 | | |
959 | 959 | | |
960 | | - | |
961 | | - | |
962 | 960 | | |
963 | | - | |
| 961 | + | |
964 | 962 | | |
965 | 963 | | |
966 | 964 | | |
967 | 965 | | |
968 | 966 | | |
969 | | - | |
970 | | - | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
971 | 971 | | |
972 | 972 | | |
973 | 973 | | |
| |||
993 | 993 | | |
994 | 994 | | |
995 | 995 | | |
996 | | - | |
| 996 | + | |
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
| |||
1007 | 1007 | | |
1008 | 1008 | | |
1009 | 1009 | | |
1010 | | - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
1011 | 1016 | | |
1012 | 1017 | | |
1013 | 1018 | | |
| |||
1016 | 1021 | | |
1017 | 1022 | | |
1018 | 1023 | | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
1019 | 1027 | | |
1020 | 1028 | | |
1021 | 1029 | | |
1022 | 1030 | | |
1023 | 1031 | | |
1024 | 1032 | | |
| 1033 | + | |
| 1034 | + | |
1025 | 1035 | | |
1026 | 1036 | | |
1027 | 1037 | | |
| |||
1063 | 1073 | | |
1064 | 1074 | | |
1065 | 1075 | | |
1066 | | - | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
1067 | 1079 | | |
1068 | 1080 | | |
1069 | 1081 | | |
| |||
1115 | 1127 | | |
1116 | 1128 | | |
1117 | 1129 | | |
1118 | | - | |
1119 | | - | |
1120 | 1130 | | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | 1131 | | |
1126 | 1132 | | |
1127 | 1133 | | |
| |||
0 commit comments