Commit d357dd8
cxl/region: Convert cxl_pmem_region_alloc to scope-based resource management
A recent bugfix to cxl_pmem_region_alloc() to fix an
error-unwind-memleak [1], highlighted a use case for scope-based resource
management.
Delete the goto for releasing @cxl_region_rwsem, and return error codes
directly from error condition paths.
The caller, devm_cxl_add_pmem_region(), is no longer given @cxlr_pmem
directly it must retrieve it from @cxlr->cxlr_pmem. This retrieval from
@CXLR was already in place for @cxlr->cxl_nvb, and converting
cxl_pmem_region_alloc() to return an int makes it less awkward to handle
no_free_ptr().
Cc: Li Zhijian <lizhijian@fujitsu.com>
Reported-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Closes: http://lore.kernel.org/r/20240430174540.000039ce@Huawei.com
Link: http://lore.kernel.org/r/20240428030748.318985-1-lizhijian@fujitsu.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/171451430965.1147997.15782562063090960666.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>1 parent e4ff70a commit d357dd8
1 file changed
Lines changed: 17 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2816 | 2816 | | |
2817 | 2817 | | |
2818 | 2818 | | |
2819 | | - | |
| 2819 | + | |
2820 | 2820 | | |
2821 | 2821 | | |
2822 | 2822 | | |
2823 | | - | |
2824 | 2823 | | |
2825 | 2824 | | |
2826 | 2825 | | |
2827 | | - | |
2828 | | - | |
2829 | | - | |
2830 | | - | |
2831 | | - | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
2832 | 2829 | | |
2833 | | - | |
2834 | | - | |
2835 | | - | |
2836 | | - | |
2837 | | - | |
2838 | | - | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
2839 | 2834 | | |
2840 | 2835 | | |
2841 | 2836 | | |
| |||
2853 | 2848 | | |
2854 | 2849 | | |
2855 | 2850 | | |
2856 | | - | |
2857 | | - | |
2858 | | - | |
2859 | | - | |
2860 | | - | |
| 2851 | + | |
| 2852 | + | |
2861 | 2853 | | |
2862 | 2854 | | |
2863 | 2855 | | |
| |||
2868 | 2860 | | |
2869 | 2861 | | |
2870 | 2862 | | |
2871 | | - | |
2872 | | - | |
2873 | 2863 | | |
2874 | 2864 | | |
2875 | 2865 | | |
2876 | 2866 | | |
2877 | 2867 | | |
2878 | 2868 | | |
2879 | | - | |
2880 | | - | |
| 2869 | + | |
| 2870 | + | |
2881 | 2871 | | |
2882 | | - | |
| 2872 | + | |
2883 | 2873 | | |
2884 | 2874 | | |
2885 | 2875 | | |
| |||
2996 | 2986 | | |
2997 | 2987 | | |
2998 | 2988 | | |
2999 | | - | |
3000 | | - | |
3001 | | - | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
3002 | 2993 | | |
3003 | 2994 | | |
3004 | 2995 | | |
| |||
0 commit comments