From: Markus Elfring <Markus.Elfring@web.de>
To: Guangshuo Li <lgs201920130244@gmail.com>,
kernel-janitors@vger.kernel.org
Cc: Dan Williams <djbw@kernel.org>, Kees Cook <kees@kernel.org>,
Maciej Sosnowski <maciej.sosnowski@intel.com>,
stable@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dca: fix provider device memory leak on domain allocation failure
Date: Tue, 22 Sep 2026 11:15:26 +0200 [thread overview]
Message-ID: <aa283243-da00-4461-b6a7-39c1454d6bf5@web.de> (raw)
In-Reply-To: <CANUHTR-um24oLb-446LRtHLFBGtJ7h=QwEksSjvig-SFonJpRQ@mail.gmail.com>
>> …
>>> +++ 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
next prev parent reply other threads:[~2026-09-22 9:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 17:59 Guangshuo Li
2026-09-21 11:30 ` Markus Elfring
2026-09-22 8:20 ` Guangshuo Li
2026-09-22 9:15 ` Markus Elfring [this message]
2026-09-21 15:12 ` krzk
2026-09-22 2:48 ` Guangshuo Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aa283243-da00-4461-b6a7-39c1454d6bf5@web.de \
--to=markus.elfring@web.de \
--cc=djbw@kernel.org \
--cc=kees@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.sosnowski@intel.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®