Commit c98a491
fix: Close() deadlock when read loop holds fdMu during blocking ioctl
The read loop holds fdMu.RLock across a blocking BINDER_WRITE_READ ioctl.
Close() tried to take fdMu.Lock (write) before closing the fd, creating a
deadlock: the ioctl won't return until the fd is closed, but Close() can't
close the fd until the ioctl releases RLock.
Fix: close the raw fd first to interrupt blocked ioctls with EBADF, then
take fdMu.Lock to invalidate the fd field. No new Transact calls can
start because d.closed is already set.
Also fix camera_connect example: replace os.Exit(0) with return so
deferred drv.Close runs, and add Disconnect call on success path.1 parent 627a8e7 commit c98a491
2 files changed
Lines changed: 30 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
119 | 127 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
232 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
233 | 249 | | |
234 | 250 | | |
235 | 251 | | |
| |||
241 | 257 | | |
242 | 258 | | |
243 | 259 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | 260 | | |
251 | 261 | | |
252 | 262 | | |
| |||
0 commit comments