Commit e29a899
committed
cxl/region: Fix region reference target accounting
Dan reports:
The error handling in cxl_port_attach_region() looks like it might
have a similar bug. The cxl_rr->nr_targets++; might want a --.
That function is more complicated.
Indeed cxl_rr->nr_targets leaks when cxl_rr_ep_add() fails, but that
flow is not clear. Fix the bug and the clarity by separating the 'new'
region-reference case from the 'extend' region-reference case. This also
moves the host-physical-address (HPA) validation, that the HPA of a new
region being accounted to the port is greater than the HPA of all other
regions associated with the port, to alloc_region_ref().
Introduce @nr_targets_inc to track when the error exit path needs to
clean up cxl_rr->nr_targets.
Fixes: 384e624 ("cxl/region: Attach endpoint decoders")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: http://lore.kernel.org/r/165939482134.252363.1915691883146696327.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>1 parent 69c9961 commit e29a899
1 file changed
Lines changed: 43 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
651 | | - | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
652 | 654 | | |
653 | 655 | | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
654 | 668 | | |
655 | 669 | | |
656 | | - | |
| 670 | + | |
657 | 671 | | |
658 | 672 | | |
659 | 673 | | |
| |||
665 | 679 | | |
666 | 680 | | |
667 | 681 | | |
668 | | - | |
| 682 | + | |
669 | 683 | | |
670 | 684 | | |
671 | 685 | | |
| |||
740 | 754 | | |
741 | 755 | | |
742 | 756 | | |
743 | | - | |
744 | | - | |
745 | | - | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
746 | 760 | | |
747 | 761 | | |
748 | 762 | | |
749 | 763 | | |
750 | 764 | | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
| 765 | + | |
765 | 766 | | |
766 | 767 | | |
767 | 768 | | |
768 | 769 | | |
769 | | - | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
770 | 776 | | |
771 | 777 | | |
772 | 778 | | |
| |||
777 | 783 | | |
778 | 784 | | |
779 | 785 | | |
780 | | - | |
781 | | - | |
| 786 | + | |
| 787 | + | |
782 | 788 | | |
783 | | - | |
| 789 | + | |
784 | 790 | | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
785 | 799 | | |
786 | 800 | | |
787 | | - | |
| 801 | + | |
788 | 802 | | |
789 | 803 | | |
790 | 804 | | |
791 | | - | |
| 805 | + | |
792 | 806 | | |
793 | | - | |
| 807 | + | |
794 | 808 | | |
795 | | - | |
796 | 809 | | |
797 | 810 | | |
798 | 811 | | |
| |||
835 | 848 | | |
836 | 849 | | |
837 | 850 | | |
| 851 | + | |
| 852 | + | |
838 | 853 | | |
839 | 854 | | |
840 | 855 | | |
| |||
0 commit comments