From: Alex Elder <elder@ieee.org>
To: Thomas Fourier <fourier.thomas@gmail.com>
Cc: Alex Elder <elder@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"open list:QCOM IPA DRIVER" <netdev@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net,v2] net: ipa: Fix double free of the interrupt structure on config error
Date: Thu, 29 Oct 2026 12:55:33 -0500 [thread overview]
Message-ID: <9879e94a-6fbe-4158-a21e-64b147a580bc@ieee.org> (raw)
In-Reply-To: <20261029082100.17722-2-fourier.thomas@gmail.com>
On 10/29/26 3:20 AM, Thomas Fourier wrote:
> Since ipa_interrupt_init() allocates struct ipa_interrupt in ipa_probe(),
> the structure is owned by ipa_probe() and released with
> ipa_interrupt_exit() on its error paths and in ipa_remove(). The error
> path of ipa_interrupt_config() still frees it with kfree(). If
> ipa_interrupt_config() fails (called from ipa_config() via ipa_setup()),
> ipa_probe() unwinds through err_interrupt_exit, which frees the same
> structure again.
>
> Drop the kfree() from ipa_interrupt_config(); it should only undo what it
> set up itself. Drop the leftover initialization and cleanup of
> ipa->interrupt now managed in ipa_proble() and ipa_remove() of ipa_main.c.
>
> Fixes: ad1be80d7582 ("net: ipa: introduce ipa_interrupt_init()")
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
You should respond to the netdev-bot message asking for a better
explanation of how this was found and whether it was observed or
just found by inspection.
However I think this version does look good.
Reviewed-by: Alex Elder <elder@riscstar.com>
> ---
> v1->v2:
> - Drop ipa->interrupt initialization and cleanup.
>
> drivers/net/ipa/ipa_interrupt.c | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c
> index 131b9cc94201..766b094eb069 100644
> --- a/drivers/net/ipa/ipa_interrupt.c
> +++ b/drivers/net/ipa/ipa_interrupt.c
> @@ -260,10 +260,8 @@ int ipa_interrupt_config(struct ipa *ipa)
> interrupt->enabled = 0;
> interrupt->suspend_enabled = bitmap_zalloc(ipa->endpoint_count,
> GFP_KERNEL);
> - if (!interrupt->suspend_enabled) {
> - ret = -ENOMEM;
> - goto err_kfree;
> - }
> + if (!interrupt->suspend_enabled)
> + return -ENOMEM;
>
> /* Disable IPA interrupt types */
> reg = ipa_reg(ipa, IPA_IRQ_EN);
> @@ -289,8 +287,6 @@ int ipa_interrupt_config(struct ipa *ipa)
> goto err_disable_wakeup;
> }
>
> - ipa->interrupt = interrupt;
> -
> return 0;
>
> err_disable_wakeup:
> @@ -299,8 +295,6 @@ int ipa_interrupt_config(struct ipa *ipa)
> free_irq(interrupt->irq, interrupt);
> err_free_bitmap:
> bitmap_free(interrupt->suspend_enabled);
> -err_kfree:
> - kfree(interrupt);
>
> return ret;
> }
> @@ -311,8 +305,6 @@ void ipa_interrupt_deconfig(struct ipa *ipa)
> struct ipa_interrupt *interrupt = ipa->interrupt;
> struct device *dev = ipa->dev;
>
> - ipa->interrupt = NULL;
> -
> dev_pm_clear_wake_irq(dev);
> (void)device_init_wakeup(dev, false);
> free_irq(interrupt->irq, interrupt);
next prev parent reply other threads:[~2026-10-29 17:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 8:20 Thomas Fourier
2026-10-29 8:36 ` netdev-bot+sinfo
2026-10-29 17:55 ` Alex Elder [this message]
2026-10-31 2:10 ` patchwork-bot+netdevbpf
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=9879e94a-6fbe-4158-a21e-64b147a580bc@ieee.org \
--to=elder@ieee.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=elder@kernel.org \
--cc=fourier.thomas@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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®