Skip to content

Commit 98e7ab3

Browse files
davejiangdjbw
authored andcommitted
cxl: Fix device reference leak in cxl_port_perf_data_calculate()
cxl_port_perf_data_calculate() calls find_cxl_root() and does not dereference the 'struct device' in the cxl_root->port. find_cxl_root() calls get_device() and takes a reference on the port 'struct device' member. Use the __free() macro to ensure the dereference happens. Fixes: 7a4f148 ("cxl: Compute the entire CXL path latency and bandwidth data") Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/170449246681.3779673.2288926019977963333.stgit@djiang5-mobl3 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 44cd71e commit 98e7ab3

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/cxl/core/cdat.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
162162
struct xarray *dsmas_xa)
163163
{
164164
struct access_coordinate c;
165-
struct cxl_root *cxl_root;
166165
struct dsmas_entry *dent;
167166
int valid_entries = 0;
168167
unsigned long index;
@@ -174,7 +173,11 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
174173
return rc;
175174
}
176175

177-
cxl_root = find_cxl_root(port);
176+
struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port);
177+
178+
if (!cxl_root)
179+
return -ENODEV;
180+
178181
if (!cxl_root->ops || !cxl_root->ops->qos_class)
179182
return -EOPNOTSUPP;
180183

0 commit comments

Comments
 (0)