-
Notifications
You must be signed in to change notification settings - Fork 587
Commit f798488
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.
struct class is a special case: its .owner field was removed in
upstream Linux commit 6e30a66433af ("driver core: class: remove struct
module owner out of struct class"). Explicitly setting .owner for
struct class is safe on older kernels but must be conditionally
compiled out on newer kernels.
Remove the unnecessary version guards and unconditionally sets
.owner = THIS_MODULE in the affected example code.
Closes: #348 1 parent 5aabe58 commit f798488
4 files changed
+4
-11
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
148 | 148 |
| |
149 | 149 |
| |
150 | 150 |
| |
151 | - | ||
152 | 151 |
| |
153 | - | ||
154 | 152 |
| |
155 | 153 |
| |
156 | - | ||
154 | + | ||
157 | 155 |
| |
158 | 156 |
| |
159 | 157 |
| |
| |||
182 | 180 |
| |
183 | 181 |
| |
184 | 182 |
| |
185 | - | ||
186 | 183 |
| |
187 | - | ||
188 | 184 |
| |
189 | 185 |
| |
190 | 186 |
| |
|
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 |
| |
338 | + | ||
339 | + | ||
340 | + | ||
340 | 341 |
| |
341 | 342 |
| |
342 | 343 |
| |
|
0 commit comments