Re: [PATCH v13 02/15] cxl: Share CXL port upstream PCI device lookup
From: Dave Jiang
Date: Thu Sep 24 2026 - 13:26:27 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.
Ah yeah because the devm_kzalloc() forcing the goto. Essentially don't mix goto and __cleanup().
>
> Jonathan
>
>
>
>
>