Commit 41f71de
committed
Merge patch series "usb: gadget: Refactor function drivers to use __free() cleanup"
Kuen-Han Tsai <khtsai@google.com> says:
This patch series refactors the error-handling paths in the bind()
function for f_ncm, f_acm, f_ecm, and f_rndis drivers.
The current, unified goto logic in these drivers is vulnerable to a null
pointer dereference. This is caused by the cleanup logic incorrectly
handling the stale usb_request pointer after a bind/unbind cycle. This
series fixes this issue by converting the drivers to use the modern
__free() scope-based cleanup mechanism.
Patches 1-2 are preparatory, adding the endpoint pointer to struct
usb_request and defining helpers for the __free() cleanup. The remaining
four patches use this new plumbing to refactor each driver.
Future work
-----------
1. Refactor usb_ep_free_request(), usb_ep_queue(), and usb_ep_dequeue()
functions as the ep parameter becomes redudant.
2. Convert the remaining gadget function drivers to use the new __free()
cleanup mechanism.
Link: https://lore.kernel.org/r/20250916-ready-v1-0-4997bf277548@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>6 files changed
Lines changed: 135 additions & 146 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| |||
613 | 616 | | |
614 | 617 | | |
615 | 618 | | |
| 619 | + | |
616 | 620 | | |
617 | 621 | | |
618 | 622 | | |
| |||
630 | 634 | | |
631 | 635 | | |
632 | 636 | | |
633 | | - | |
| 637 | + | |
634 | 638 | | |
635 | 639 | | |
636 | 640 | | |
| |||
639 | 643 | | |
640 | 644 | | |
641 | 645 | | |
642 | | - | |
| 646 | + | |
643 | 647 | | |
644 | 648 | | |
645 | 649 | | |
646 | 650 | | |
647 | 651 | | |
648 | 652 | | |
649 | | - | |
650 | | - | |
651 | 653 | | |
652 | 654 | | |
653 | 655 | | |
654 | | - | |
| 656 | + | |
655 | 657 | | |
656 | 658 | | |
657 | 659 | | |
658 | 660 | | |
659 | | - | |
| 661 | + | |
660 | 662 | | |
661 | 663 | | |
662 | 664 | | |
663 | 665 | | |
664 | | - | |
| 666 | + | |
665 | 667 | | |
666 | 668 | | |
667 | 669 | | |
668 | 670 | | |
669 | 671 | | |
670 | 672 | | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
676 | 678 | | |
677 | | - | |
678 | | - | |
| 679 | + | |
| 680 | + | |
679 | 681 | | |
680 | 682 | | |
681 | 683 | | |
| |||
692 | 694 | | |
693 | 695 | | |
694 | 696 | | |
695 | | - | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
696 | 700 | | |
697 | 701 | | |
698 | 702 | | |
699 | 703 | | |
700 | 704 | | |
701 | 705 | | |
702 | 706 | | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | 707 | | |
712 | 708 | | |
713 | 709 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
678 | 681 | | |
679 | 682 | | |
680 | 683 | | |
| 684 | + | |
681 | 685 | | |
682 | 686 | | |
683 | 687 | | |
| |||
711 | 715 | | |
712 | 716 | | |
713 | 717 | | |
714 | | - | |
| 718 | + | |
715 | 719 | | |
716 | 720 | | |
717 | 721 | | |
| |||
720 | 724 | | |
721 | 725 | | |
722 | 726 | | |
723 | | - | |
| 727 | + | |
724 | 728 | | |
725 | 729 | | |
726 | 730 | | |
727 | 731 | | |
728 | 732 | | |
729 | 733 | | |
730 | | - | |
731 | | - | |
732 | 734 | | |
733 | 735 | | |
734 | 736 | | |
735 | | - | |
| 737 | + | |
736 | 738 | | |
737 | 739 | | |
738 | 740 | | |
739 | 741 | | |
740 | | - | |
| 742 | + | |
741 | 743 | | |
742 | 744 | | |
743 | 745 | | |
| |||
746 | 748 | | |
747 | 749 | | |
748 | 750 | | |
749 | | - | |
| 751 | + | |
750 | 752 | | |
751 | 753 | | |
752 | | - | |
753 | | - | |
754 | 754 | | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
763 | 763 | | |
764 | 764 | | |
765 | 765 | | |
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
781 | | - | |
| 781 | + | |
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
| |||
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
| 791 | + | |
| 792 | + | |
791 | 793 | | |
792 | 794 | | |
793 | 795 | | |
794 | 796 | | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | 797 | | |
806 | 798 | | |
807 | 799 | | |
| |||
0 commit comments