Commit f49856f
udmabuf: fix memory leak on last export_udmabuf() error path
In export_udmabuf(), if dma_buf_fd() fails because the FD table is full, a
dma_buf owning the udmabuf has already been created; but the error handling
in udmabuf_create() will tear down the udmabuf without doing anything about
the containing dma_buf.
This leaves a dma_buf in memory that contains a dangling pointer; though
that doesn't seem to lead to anything bad except a memory leak.
Fix it by moving the dma_buf_fd() call out of export_udmabuf() so that we
can give it different error handling.
Note that the shape of this code changed a lot in commit 5e72b2b
("udmabuf: convert udmabuf driver to use folios"); but the memory leak
seems to have existed since the introduction of udmabuf.
Fixes: fbb0de7 ("Add udmabuf misc device")
Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241204-udmabuf-fixes-v2-3-23887289de1c@google.com1 parent 0a16e24 commit f49856f
1 file changed
+17
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | | - | |
321 | | - | |
322 | | - | |
| 320 | + | |
| 321 | + | |
323 | 322 | | |
324 | 323 | | |
325 | | - | |
326 | 324 | | |
327 | 325 | | |
328 | 326 | | |
329 | 327 | | |
330 | 328 | | |
331 | 329 | | |
332 | 330 | | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 331 | + | |
338 | 332 | | |
339 | 333 | | |
340 | 334 | | |
| |||
391 | 385 | | |
392 | 386 | | |
393 | 387 | | |
| 388 | + | |
394 | 389 | | |
395 | 390 | | |
396 | 391 | | |
| |||
455 | 450 | | |
456 | 451 | | |
457 | 452 | | |
458 | | - | |
459 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
460 | 456 | | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
461 | 467 | | |
462 | 468 | | |
463 | 469 | | |
| |||
0 commit comments