From: sashiko-bot@kernel.org
To: "Lee Jones" <lee@kernel.org>, dmaengine@vger.kernel.org
Cc: vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH 07/10] dmaengine: bestcomm: Defer publishing bcom_eng until initialisation completes
Date: Wed, 11 Nov 2026 22:26:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-209788@kernel.org> (raw)
In-Reply-To: <20261111215349.1983909-8-lee@kernel.org>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] dmaengine: bestcomm: use-after-free in bcom_task_alloc()
[1]
--
commit 0c7452c3ef4427c8251608e31eaba52df094162d
Author: Lee Jones <lee@kernel.org>
dmaengine: bestcomm: Defer publishing bcom_eng until initialisation completes
This commit initializes struct bcom_engine via a local pointer and defers
publishing it to the global bcom_eng pointer until initialization in
bcom_engine_init() has completed.
> diff --git a/drivers/dma/bestcomm/bestcomm.c b/drivers/dma/bestcomm/bestcomm.c
> index 241a91936fe8a..dbc3ce5fc4462 100644
> --- a/drivers/dma/bestcomm/bestcomm.c
> +++ b/drivers/dma/bestcomm/bestcomm.c
[ ... ]
> @@ -398,20 +402,20 @@ static int mpc52xx_bcom_probe(struct platform_device *op)
> }
>
> /* Get a clean struct */
> - bcom_eng = kzalloc_obj(struct bcom_engine);
> - if (!bcom_eng) {
> + eng = kzalloc_obj(struct bcom_engine);
> + if (!eng) {
> rv = -ENOMEM;
> goto error_sramclean;
> }
>
> /* Save the node */
> - bcom_eng->ofnode = op->dev.of_node;
> + eng->ofnode = op->dev.of_node;
>
> - bcom_eng->regs = regs;
> - bcom_eng->regs_base = res_bcom->start;
> + eng->regs = regs;
> + eng->regs_base = res_bcom->start;
>
> /* Now, do the real init */
> - rv = bcom_engine_init();
> + rv = bcom_engine_init(eng);
> if (rv)
> goto error_sramclean;
>
> @@ -423,8 +427,7 @@ static int mpc52xx_bcom_probe(struct platform_device *op)
>
> /* Error path */
> error_sramclean:
> - kfree(bcom_eng);
> - bcom_eng = NULL;
> + kfree(eng);
> bcom_sram_cleanup();
> error_ofput:
> of_node_put(op->dev.of_node);
[Severity: Critical]
This problem wasn't introduced by this patch, but can mpc52xx_bcom_remove()
trigger a use-after-free in bcom_task_alloc() [1]?
While this patch fixes premature publication of bcom_eng during probe,
mpc52xx_bcom_remove() frees bcom_eng before clearing the global pointer and
without synchronizing against concurrent bcom_task_alloc() callers:
CPU0 CPU1
bcom_task_alloc()
if (!bcom_eng)
mpc52xx_bcom_remove()
kfree(bcom_eng);
bcom_eng = NULL;
spin_lock(&bcom_eng->lock); <-- use-after-free
[1] https://sashiko.dev/#/bug/linux-149609ff-866f-4c27-8adf-ef935bca5f89
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111215349.1983909-1-lee@kernel.org?part=7
next prev parent reply other threads:[~2026-11-11 22:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 21:52 [PATCH 00/10] dmaengine: Fix teardown races, resource leaks, and error handling Lee Jones
2026-11-11 21:52 ` [PATCH 01/10] dmaengine: pl08x: Defer OF DMA controller registration until slave setup Lee Jones
2026-11-11 21:52 ` [PATCH 02/10] dmaengine: ae4dma: Unregister DMA engine in ae4_pci_remove() Lee Jones
2026-11-11 22:32 ` sashiko-bot
2026-11-11 21:52 ` [PATCH 03/10] dmaengine: ptdma: Unmap descriptor in pt_do_cleanup() Lee Jones
2026-11-11 21:52 ` [PATCH 04/10] dmaengine: ptdma: Remove completed descriptor under vc.lock in pt_cmd_callback_work() Lee Jones
2026-11-11 21:52 ` [PATCH 05/10] dmaengine: amlogic: Destroy free_wq after devres DMA device unregistration Lee Jones
2026-11-11 22:23 ` sashiko-bot
2026-11-11 21:52 ` [PATCH 06/10] dmaengine: arm-dma350: Query dma_cookie_status() under vc.lock in d350_tx_status() Lee Jones
2026-11-11 21:52 ` [PATCH 07/10] dmaengine: bestcomm: Defer publishing bcom_eng until initialisation completes Lee Jones
2026-11-11 22:26 ` sashiko-bot [this message]
2026-11-11 21:52 ` [PATCH 08/10] dmaengine: bestcomm: Check rh_create() return value in bcom_sram_init() Lee Jones
2026-11-11 21:52 ` [PATCH 09/10] dmaengine: jz4780: Fix descriptor cleanup on hwdesc setup failure Lee Jones
2026-11-11 22:26 ` sashiko-bot
2026-11-11 21:52 ` [PATCH 10/10] dmaengine: dmatest: Avoid unsigned underflow in min_odd() Lee Jones
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=sashiko-outbox-209788@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=lee@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@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