[PATCH v2 2/2] cxl/region: Use __free(put_device) in find_pos_and_ways()
Alison Schofield <[email protected]>
| Newsgroups | org.kernel.vger.linux-cxl |
|---|---|
| Message-ID | <03aceaa0001651c28f221988c9e845f59bf1d84d.1784654628.git.alison.schofield@intel.com> |
Use __free(put_device) for the switch decoder reference returned by device_find_child() instead of releasing it with an open-coded put_device(). This matches the scoped device reference handling used elsewhere in the file. Suggested-by: Li Ming <[email protected]> Signed-off-by: Alison Schofield <[email protected]> --- This is a new patch added in series after the UAF fixup in patch 1/2. drivers/cxl/core/region.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index c86dd9d55e93..4d7d96d03ece 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1911,9 +1911,9 @@ static int match_switch_decoder_by_range(struct device *dev, static int find_pos_and_ways(struct cxl_port *port, struct range *range, int *pos, int *ways) { + struct device *dev __free(put_device) = NULL; struct cxl_switch_decoder *cxlsd; struct cxl_port *parent; - struct device *dev; int rc = -ENXIO; parent = parent_port_of(port); @@ -1945,8 +1945,6 @@ static int find_pos_and_ways(struct cxl_port *port, struct range *range, dev_name(port->parent_dport->dport_dev), dev_name(&cxlsd->cxld.dev)); - put_device(dev); - return rc; } -- 2.37.3