Skip to content

Commit ace196d

Browse files
davejiangdjbw
authored andcommitted
cxl: Fix unregister_region() callback parameter assignment
In devm_cxl_add_region(), devm_add_action_or_reset() is called by passing in unregister_region() with data ptr of 'cxlr'. However, in unregister_region(), the passed in parameter is incorrectly assumed to be a 'struct device' rather than the 'cxlr' pointer. The code has been working because 'struct device' is the first member of 'struct cxl_region'. Issue found by inspection. Fix the assignment so that cxlr is pointing directly to the passed in parameter. Not flagged for -stable since there is no functional impact of this fix. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Link: https://lore.kernel.org/r/170258123810.952211.3907381447996426480.stgit@djiang5-mobl3 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent cb46fca commit ace196d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/cxl/core/region.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,13 +2083,13 @@ static struct cxl_region *to_cxl_region(struct device *dev)
20832083
return container_of(dev, struct cxl_region, dev);
20842084
}
20852085

2086-
static void unregister_region(void *dev)
2086+
static void unregister_region(void *_cxlr)
20872087
{
2088-
struct cxl_region *cxlr = to_cxl_region(dev);
2088+
struct cxl_region *cxlr = _cxlr;
20892089
struct cxl_region_params *p = &cxlr->params;
20902090
int i;
20912091

2092-
device_del(dev);
2092+
device_del(&cxlr->dev);
20932093

20942094
/*
20952095
* Now that region sysfs is shutdown, the parameter block is now
@@ -2100,7 +2100,7 @@ static void unregister_region(void *dev)
21002100
detach_target(cxlr, i);
21012101

21022102
cxl_region_iomem_release(cxlr);
2103-
put_device(dev);
2103+
put_device(&cxlr->dev);
21042104
}
21052105

21062106
static struct lock_class_key cxl_region_key;

0 commit comments

Comments
 (0)