Re: [PATCH] dca: fix provider device memory leak on domain allocation failure
From: Markus Elfring
Date: Tue Sep 22 2026 - 05:23:19 EST
>> …
>>> +++ b/drivers/dca/dca-core.c
>>> @@ -368,8 +368,11 @@ int register_dca_provider(struct dca_provider *dca, struct device *dev)
>>> raw_spin_unlock_irqrestore(&dca_lock, flags);
>>> rc = dca_pci_rc_from_dev(dev);
>>> newdomain = dca_allocate_domain(rc);
>>> - if (!newdomain)
>>> + if (!newdomain) {
>>> + dca_sysfs_remove_provider(dca);
>>> return -ENODEV;
>>> + }
>>> +
>>> raw_spin_lock_irqsave(&dca_lock, flags);
>> …
>>
>> Please avoid a bit of duplicate source code in this function implementation
>> by using another goto chain.
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v7.3-rc4#n572
>>
>> https://elixir.bootlin.com/linux/v7.3-rc3/source/drivers/dca/dca-core.c#L335-L389
…
> Do you mean using a common error path like this?
…
> return 0;
> +
> +err_remove_provider:
> + dca_sysfs_remove_provider(dca);
> + return -ENODEV;
> }
Yes.
> Would this be the preferred change? …
Coding style preferences are also evolving into further directions.
Regards,
Markus