Re: [PATCH] dca: fix provider device memory leak on domain allocation failure

From: Markus Elfring

Date: Mon Sep 21 2026 - 07:35:47 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

Regards,
Markus