Commit 383d4f5
spi: spi-sprd-adi: Fix double free in probe error path
The driver currently uses spi_alloc_host() to allocate the controller
but registers it using devm_spi_register_controller().
If devm_register_restart_handler() fails, the code jumps to the
put_ctlr label and calls spi_controller_put(). However, since the
controller was registered via a devm function, the device core will
automatically call spi_controller_put() again when the probe fails.
This results in a double-free of the spi_controller structure.
Fix this by switching to devm_spi_alloc_host() and removing the
manual spi_controller_put() call.
Fixes: ac17750 ("spi: sprd: Add the support of restarting the system")
Signed-off-by: Felix Gu <gu_0233@qq.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://patch.msgid.link/tencent_AC7D389CE7E24318445E226F7CDCCC2F0D07@qq.com
Signed-off-by: Mark Brown <broonie@kernel.org>1 parent 9ace475 commit 383d4f5
1 file changed
Lines changed: 10 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
531 | | - | |
| 531 | + | |
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
| 539 | + | |
| 540 | + | |
543 | 541 | | |
544 | 542 | | |
545 | 543 | | |
| |||
551 | 549 | | |
552 | 550 | | |
553 | 551 | | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
| 552 | + | |
| 553 | + | |
558 | 554 | | |
559 | 555 | | |
560 | 556 | | |
561 | 557 | | |
562 | 558 | | |
563 | 559 | | |
564 | | - | |
565 | | - | |
| 560 | + | |
566 | 561 | | |
567 | 562 | | |
568 | 563 | | |
| |||
579 | 574 | | |
580 | 575 | | |
581 | 576 | | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
| 577 | + | |
| 578 | + | |
586 | 579 | | |
587 | 580 | | |
588 | 581 | | |
589 | 582 | | |
590 | 583 | | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
| 584 | + | |
| 585 | + | |
595 | 586 | | |
596 | 587 | | |
597 | 588 | | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | 589 | | |
603 | 590 | | |
604 | 591 | | |
| |||
0 commit comments