Commit bef4a48
spi: Fix null dereference on suspend
A race condition exists where a synchronous (noqueue) transfer can be
active during a system suspend. This can cause a null pointer
dereference exception to occur when the system resumes.
Example order of events leading to the exception:
1. spi_sync() calls __spi_transfer_message_noqueue() which sets
ctlr->cur_msg
2. Spi transfer begins via spi_transfer_one_message()
3. System is suspended interrupting the transfer context
4. System is resumed
6. spi_controller_resume() calls spi_start_queue() which resets cur_msg
to NULL
7. Spi transfer context resumes and spi_finalize_current_message() is
called which dereferences cur_msg (which is now NULL)
Wait for synchronous transfers to complete before suspending by
acquiring the bus mutex and setting/checking a suspend flag.
Signed-off-by: Mark Hasemeyer <markhas@chromium.org>
Link: https://lore.kernel.org/r/20231107144743.v1.1.I7987f05f61901f567f7661763646cb7d7919b528@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@kernel.org1 parent c2ded28 commit bef4a48
2 files changed
+40
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3317 | 3317 | | |
3318 | 3318 | | |
3319 | 3319 | | |
| 3320 | + | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
3320 | 3339 | | |
3321 | 3340 | | |
3322 | | - | |
| 3341 | + | |
3323 | 3342 | | |
3324 | 3343 | | |
3325 | | - | |
3326 | | - | |
3327 | | - | |
3328 | | - | |
3329 | | - | |
3330 | | - | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
3331 | 3349 | | |
| 3350 | + | |
3332 | 3351 | | |
3333 | 3352 | | |
3334 | 3353 | | |
3335 | 3354 | | |
3336 | 3355 | | |
3337 | 3356 | | |
3338 | | - | |
3339 | | - | |
3340 | | - | |
3341 | | - | |
| 3357 | + | |
3342 | 3358 | | |
3343 | | - | |
3344 | | - | |
3345 | | - | |
| 3359 | + | |
3346 | 3360 | | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
3347 | 3366 | | |
3348 | 3367 | | |
3349 | 3368 | | |
| |||
4147 | 4166 | | |
4148 | 4167 | | |
4149 | 4168 | | |
4150 | | - | |
4151 | | - | |
| 4169 | + | |
4152 | 4170 | | |
4153 | 4171 | | |
4154 | 4172 | | |
| |||
4164 | 4182 | | |
4165 | 4183 | | |
4166 | 4184 | | |
4167 | | - | |
4168 | 4185 | | |
4169 | 4186 | | |
4170 | 4187 | | |
| |||
4187 | 4204 | | |
4188 | 4205 | | |
4189 | 4206 | | |
| 4207 | + | |
| 4208 | + | |
| 4209 | + | |
| 4210 | + | |
| 4211 | + | |
4190 | 4212 | | |
4191 | 4213 | | |
4192 | 4214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| 569 | + | |
569 | 570 | | |
570 | 571 | | |
571 | 572 | | |
| |||
0 commit comments