mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Lee Jones <lee@kernel.org>
Cc: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
	Sylvain Munaut <tnt@246tnt.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 09/11] dmaengine: bestcomm: Check rh_create() return value in bcom_sram_init()
Date: Tue, 17 Nov 2026 14:49:22 -0500	[thread overview]
Message-ID: <avyvwqRiVWq6PCr9@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20261117163809.622249-10-lee@kernel.org>

On Tue, Nov 17, 2026 at 04:37:10PM +0000, Lee Jones wrote:
> rh_create() returns ERR_PTR(-ENOMEM) on allocation failure.
> bcom_sram_init() assigns this return value directly to bcom_sram->rh
> without checking IS_ERR() and passes it to rh_attach_region(), which
> dereferences the error pointer.
>
> Check IS_ERR(bcom_sram->rh) after rh_create() and unmap the SRAM region
> on failure.
>
> Fixes: 2f9ea1bde0d1 ("[POWERPC] bestcomm: core bestcomm support for Freescale MPC5200")
> Closes: https://sashiko.dev/#/bug/linux-c3caaf6f-9a88-4451-b40e-d061c1fdeabd
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>
> v1 => v2: No changes
>
>  drivers/dma/bestcomm/sram.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/dma/bestcomm/sram.c b/drivers/dma/bestcomm/sram.c
> index 09ef5142c26c..df4d90cee465 100644
> --- a/drivers/dma/bestcomm/sram.c
> +++ b/drivers/dma/bestcomm/sram.c
> @@ -88,6 +88,10 @@ int bcom_sram_init(struct device_node *sram_node, char *owner)
>
>  	/* Create an rheap (defaults to 32 bits word alignment) */
>  	bcom_sram->rh = rh_create(4);
> +	if (IS_ERR(bcom_sram->rh)) {
> +		rv = PTR_ERR(bcom_sram->rh);
> +		goto error_unmap;
> +	}
>
>  	/* Attach the free zones */
>  	regaddr_p = NULL;
> @@ -111,6 +115,8 @@ int bcom_sram_init(struct device_node *sram_node, char *owner)
>
>  	return 0;
>
> +error_unmap:
> +	iounmap((void __iomem *)bcom_sram->base_virt);
>  error_release:
>  	release_mem_region(res.start, resource_size(&res));
>  error_free:
> --
> 2.56.0.679.gc527c65306-goog
>

  reply	other threads:[~2026-11-17 19:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 16:37 [PATCH v2 00/11] dmaengine: Fix teardown races, resource leaks, and error handling Lee Jones
2026-11-17 16:37 ` [PATCH v2 01/11] dmaengine: pl08x: Defer OF DMA controller registration until slave setup Lee Jones
2026-11-17 18:44   ` Linus Walleij
2026-11-17 19:37   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 02/11] dmaengine: ae4dma: Let the pending work exit before cancelling it Lee Jones
2026-11-17 19:38   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 03/11] dmaengine: ae4dma: Unregister DMA engine in ae4_pci_remove() Lee Jones
2026-11-17 19:40   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 04/11] dmaengine: ptdma: Unmap descriptor in pt_do_cleanup() Lee Jones
2026-11-17 19:41   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 05/11] dmaengine: ptdma: Remove completed descriptor under vc.lock in pt_cmd_callback_work() Lee Jones
2026-11-17 19:42   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 06/11] dmaengine: amlogic: Destroy free_wq after devres DMA device unregistration Lee Jones
2026-11-17 19:43   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 07/11] dmaengine: arm-dma350: Query dma_cookie_status() under vc.lock in d350_tx_status() Lee Jones
2026-11-17 19:44   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 08/11] dmaengine: bestcomm: Defer publishing bcom_eng until initialisation completes Lee Jones
2026-11-17 19:48   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 09/11] dmaengine: bestcomm: Check rh_create() return value in bcom_sram_init() Lee Jones
2026-11-17 19:49   ` Frank Li [this message]
2026-11-17 16:37 ` [PATCH v2 10/11] dmaengine: jz4780: Fix descriptor cleanup on hwdesc setup failure Lee Jones
2026-11-17 19:50   ` Frank Li
2026-11-17 19:54   ` Paul Cercueil
2026-11-17 16:37 ` [PATCH v2 11/11] dmaengine: dmatest: Avoid unsigned underflow in min_odd() Lee Jones
2026-11-17 19:51   ` Frank 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=avyvwqRiVWq6PCr9@lizhi-Precision-Tower-5810 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=grant.likely@secretlab.ca \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tnt@246tnt.com \
    --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

all inboxes | Powered by JetHome®