Commit 5bc9e2d
ata: pata_parport: fix memory leaks
When ida_alloc() fails, "pi" is not freed although the misleading
comment says otherwise.
Move the ida_alloc() call up so we really don't have to free "pi" in
case of ida_alloc() failure.
Also move ida_free() call from pi_remove_one() to
pata_parport_dev_release(). It was dereferencing already freed dev
pointer.
Testing revealed leak even in non-failure case which was tracked down
to missing put_device() call after bus_find_device_by_name(). As a
result, pata_parport_dev_release() was never called.
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Link: https://lore.kernel.org/r/[email protected]/
Signed-off-by: Ondrej Zary <[email protected]>
Signed-off-by: Damien Le Moal <[email protected]>1 parent dc472c7 commit 5bc9e2d
1 file changed
Lines changed: 14 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| 384 | + | |
384 | 385 | | |
385 | 386 | | |
386 | 387 | | |
| |||
433 | 434 | | |
434 | 435 | | |
435 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
436 | 441 | | |
437 | | - | |
| 442 | + | |
| 443 | + | |
438 | 444 | | |
| 445 | + | |
439 | 446 | | |
440 | 447 | | |
441 | 448 | | |
442 | 449 | | |
443 | 450 | | |
444 | 451 | | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | 452 | | |
449 | 453 | | |
450 | 454 | | |
451 | 455 | | |
452 | | - | |
| 456 | + | |
| 457 | + | |
453 | 458 | | |
454 | 459 | | |
455 | 460 | | |
| |||
464 | 469 | | |
465 | 470 | | |
466 | 471 | | |
467 | | - | |
468 | | - | |
| 472 | + | |
469 | 473 | | |
470 | 474 | | |
471 | 475 | | |
| |||
501 | 505 | | |
502 | 506 | | |
503 | 507 | | |
504 | | - | |
505 | | - | |
| 508 | + | |
506 | 509 | | |
507 | 510 | | |
508 | 511 | | |
| |||
627 | 630 | | |
628 | 631 | | |
629 | 632 | | |
630 | | - | |
631 | | - | |
| 633 | + | |
632 | 634 | | |
633 | 635 | | |
634 | 636 | | |
| |||
644 | 646 | | |
645 | 647 | | |
646 | 648 | | |
| 649 | + | |
647 | 650 | | |
648 | 651 | | |
649 | 652 | | |
| |||
0 commit comments