Re: [PATCH 1/2] cxl/region: fix region leak when attach_target fails in cxl_add_to_region

kernel test robot
2026-02-21T10:37:06Z

Hi Gregory,

kernel test robot noticed the following build errors:

[auto build test ERROR on cxl/next]
[also build test ERROR on linus/master next-20260220]
[cannot apply to cxl/pending v6.19]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Gregory-Price/cxl-region-skip-default-driver-attach-for-memdev-with-attach-callbacks/20260221-123300
base: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git next
patch link: https://lore.kernel.org/r/20260221043013.1420169-1-gourry%40gourry.net
patch subject: [PATCH 1/2] cxl/region: fix region leak when attach_target fails in cxl_add_to_region
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20260221/202602211806.TN3ENfmn-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260221/202602211806.TN3ENfmn-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602211806.TN3ENfmn-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/cxl/core/region.c:3964:4: error: call to undeclared function 'drop_region'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
3964 | drop_region(cxlrd, cxlr);
| ^
1 error generated.

vim +/drop_region +3964 drivers/cxl/core/region.c

3920
3921 int cxl_add_to_region(struct cxl_endpoint_decoder *cxled)
3922 {
3923 struct cxl_region_context ctx;
3924 struct cxl_region_params *p;
3925 bool attach = false;
3926 bool newly_created = false;
3927 int rc;
3928
3929 ctx = (struct cxl_region_context) {
3930 .cxled = cxled,
3931 .hpa_range = cxled->cxld.hpa_range,
3932 .interleave_ways = cxled->cxld.interleave_ways,
3933 .interleave_granularity = cxled->cxld.interleave_granularity,
3934 };
3935
3936 struct cxl_root_decoder *cxlrd __free(put_cxl_root_decoder) =
3937 get_cxl_root_decoder(cxled, &ctx);
3938
3939 if (IS_ERR(cxlrd))
3940 return PTR_ERR(cxlrd);
3941
3942 /*
3943 * Ensure that, if multiple threads race to construct_region()
3944 * for the HPA range, one does the construction and the others
3945 * add to that.
3946 */
3947 mutex_lock(&cxlrd->range_lock);
3948 struct cxl_region *cxlr __free(put_cxl_region) =
3949 cxl_find_region_by_range(cxlrd, &ctx.hpa_range);
3950 if (!cxlr) {
3951 cxlr = construct_region(cxlrd, &ctx);
3952 newly_created = !IS_ERR(cxlr);
3953 }
3954 mutex_unlock(&cxlrd->range_lock);
3955
3956 rc = PTR_ERR_OR_ZERO(cxlr);
3957 if (rc)
3958 return rc;
3959
3960 rc = attach_target(cxlr, cxled, -1, TASK_UNINTERRUPTIBLE);
3961 if (rc) {
3962 /* If endpoint was just created, tear it down to release HPA */
3963 if (newly_created)
> 3964 drop_region(cxlrd, cxlr);
3965 return rc;
3966 }
3967
3968 scoped_guard(rwsem_read, &cxl_rwsem.region) {
3969 p = &cxlr->params;
3970 attach = p->state == CXL_CONFIG_COMMIT;
3971 }
3972
3973 if (attach) {
3974 /*
3975 * If device_attach() fails the range may still be active via
3976 * the platform-firmware memory map, otherwise the driver for
3977 * regions is local to this file, so driver matching can't fail.
3978 */
3979 if (device_attach(&cxlr->dev) < 0)
3980 dev_err(&cxlr->dev, "failed to enable, range: %pr\n",
3981 p->res);
3982 }
3983
3984 return 0;
3985 }
3986 EXPORT_SYMBOL_NS_GPL(cxl_add_to_region, "CXL");
3987

--
0-DAY CI Kernel Test Service