Commit eeb25a0
committed
ata: ahci: Clean up sysfs file on error
.probe() (ahci_init_one()) calls sysfs_add_file_to_group(), however,
if probe() fails after this call, we currently never call
sysfs_remove_file_from_group().
(The sysfs_remove_file_from_group() call in .remove() (ahci_remove_one())
does not help, as .remove() is not called on .probe() error.)
Thus, if probe() fails after the sysfs_add_file_to_group() call, the next
time we insmod the module we will get:
sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:04.0/remapped_nvme'
CPU: 11 PID: 954 Comm: modprobe Not tainted 6.10.0-rc5 #43
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-2.fc40 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x5d/0x80
sysfs_warn_dup.cold+0x17/0x23
sysfs_add_file_mode_ns+0x11a/0x130
sysfs_add_file_to_group+0x7e/0xc0
ahci_init_one+0x31f/0xd40 [ahci]
Fixes: 894fba7 ("ata: ahci: Add sysfs attribute to show remapped NVMe device count")
Cc: stable@vger.kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20240629124210.181537-10-cassel@kernel.org
Signed-off-by: Niklas Cassel <cassel@kernel.org>1 parent ab9e0c5 commit eeb25a0
1 file changed
+12
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1975 | 1975 | | |
1976 | 1976 | | |
1977 | 1977 | | |
1978 | | - | |
1979 | | - | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
1980 | 1982 | | |
1981 | 1983 | | |
1982 | 1984 | | |
| |||
2031 | 2033 | | |
2032 | 2034 | | |
2033 | 2035 | | |
2034 | | - | |
| 2036 | + | |
2035 | 2037 | | |
2036 | 2038 | | |
2037 | 2039 | | |
2038 | | - | |
| 2040 | + | |
2039 | 2041 | | |
2040 | 2042 | | |
2041 | 2043 | | |
| |||
2044 | 2046 | | |
2045 | 2047 | | |
2046 | 2048 | | |
2047 | | - | |
| 2049 | + | |
2048 | 2050 | | |
2049 | 2051 | | |
2050 | 2052 | | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
2051 | 2058 | | |
2052 | 2059 | | |
2053 | 2060 | | |
| |||
0 commit comments