Re: [PATCH v13 02/15] cxl: Share CXL port upstream PCI device lookup

From: Srirangan Madhavan

Date: Thu Oct 01 2026 - 18:34:33 EST


On 9/23/26 6:21 PM, Jonathan Cameron wrote:
/*
@@ -625,11 +612,13 @@ void read_cdat_data(struct cxl_port *port)
port->cdat.table = buf->data;
port->cdat.length = length;

- return;
+ goto out;
Confusing flow, just duplicate the pci_dev_put()

err:
/* Don't leave table data allocated on error */
devm_kfree(dev, buf);
dev_err(dev, "Failed to read/validate CDAT.\n");
+out:
+ pci_dev_put(pdev);
I'd use __free() instead of introducing another goto, especially since this is the ideal
use case for it. There should be a free action defined for this, but I can't remember what
it's called.
Don't do that. See the guidance on where __free should be used in
cleanup.h. There are places where it 'could' be used but we don't
because it adds fragility under potential code refactoring.

Jonathan

Agreed. In v14 I removed the cleanup goto and duplicated pci_dev_put() at the relevant return and error paths. I did not use __free() here.

--
Regards,
Srirangan