Commit 5fba871
committed
Fix incorrect conditional usage of .owner
The examples code wrapped .owner = THIS_MODULE inside version checks,
suggesting that it is no longer needed after v6.4. This is only true
for driver types where the driver core sets .owner automatically (e.g.
platform and i2c drivers).
For structures such as struct file_operations, .owner must still be set
explicitly by the user. Without it, module reference counting will be
broken, allowing a module to be unloaded while still in use, which can
lead to kernel panics.
For struct class, the core can safely omit .owner, but explicitly
setting it remains correct and safe. Adding conditional #if checks
around it only makes the examples harder to read and more confusing for
readers.
Remove the unnecessary version guards and unconditionally sets
.owner = THIS_MODULE in the affected example code.
Closes: #3481 parent 5aabe58 commit 5fba871
4 files changed
+4
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
158 | 154 | | |
159 | 155 | | |
160 | 156 | | |
| |||
182 | 178 | | |
183 | 179 | | |
184 | 180 | | |
185 | | - | |
186 | 181 | | |
187 | | - | |
188 | 182 | | |
189 | 183 | | |
190 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | 143 | | |
145 | | - | |
146 | 144 | | |
147 | 145 | | |
148 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | | - | |
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
137 | 136 | | |
138 | | - | |
139 | 137 | | |
140 | 138 | | |
141 | 139 | | |
| |||
337 | 335 | | |
338 | 336 | | |
339 | 337 | | |
340 | | - | |
341 | 338 | | |
342 | | - | |
343 | 339 | | |
344 | 340 | | |
345 | 341 | | |
| |||
0 commit comments