Linux-SPI Archive on lore.kernel.org
 help / color / Atom feed
From: Ikjoon Jang <ikjn@chromium.org>
To: Lukas Wunner <lukas@wunner.de>
Cc: Mark Brown <broonie@kernel.org>,
	linux-spi@vger.kernel.org, Chuanhong Guo <gch981213@gmail.com>,
	Matthias Brugger <matthias.bgg@gmail.com>
Subject: Re: [PATCH for-5.10] spi: spi-mtk-nor: Don't leak SPI master in probe error path
Date: Tue, 17 Nov 2020 12:02:51 +0800
Message-ID: <CAATdQgDi_AfRvQ5Qe9yjU5xZHPm3CcVXyAd5EX4M824sg4ZDtw@mail.gmail.com> (raw)
In-Reply-To: <a203c24658b7d70ddb27bf1f9898fe6f896fead5.1605512876.git.lukas@wunner.de>

On Mon, Nov 16, 2020 at 4:43 PM Lukas Wunner <lukas@wunner.de> wrote:
>
> If the call to devm_spi_register_controller() fails on probe of the
> MediaTek SPI NOR driver, the spi_controller struct is erroneously not
> freed.
>
> Since commit a1daaa991ed1 ("spi: spi-mtk-nor: use dma_alloc_coherent()
> for bounce buffer"), the same happens if the call to
> dmam_alloc_coherent() fails.
>
> Since commit 3bfd9103c7af ("spi: spi-mtk-nor: Add power management
> support"), the same happens if the call to mtk_nor_enable_clk() fails.
>
> Fix by switching over to the new devm_spi_alloc_master() helper.
>
> Fixes: 881d1ee9fe81 ("spi: add support for mediatek spi-nor controller")
> Signed-off-by: Lukas Wunner <lukas@wunner.de>

Reviewed-by: Ikjoon Jang <ikjn@chromium.org>

> Cc: <stable@vger.kernel.org> # v5.7+: 5e844cc37a5c: spi: Introduce device-managed SPI controller allocation
> Cc: <stable@vger.kernel.org> # v5.7+
> Cc: Chuanhong Guo <gch981213@gmail.com>
> Cc: Ikjoon Jang <ikjn@chromium.org>
> ---
>  drivers/spi/spi-mtk-nor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-mtk-nor.c b/drivers/spi/spi-mtk-nor.c
> index b97f26a60cbe..288f6c2bbd57 100644
> --- a/drivers/spi/spi-mtk-nor.c
> +++ b/drivers/spi/spi-mtk-nor.c
> @@ -768,7 +768,7 @@ static int mtk_nor_probe(struct platform_device *pdev)
>                 return -EINVAL;
>         }
>
> -       ctlr = spi_alloc_master(&pdev->dev, sizeof(*sp));
> +       ctlr = devm_spi_alloc_master(&pdev->dev, sizeof(*sp));
>         if (!ctlr) {
>                 dev_err(&pdev->dev, "failed to allocate spi controller\n");
>                 return -ENOMEM;
> --
> 2.28.0
>

  reply index

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16  8:23 [PATCH for-5.10] spi: spi-geni-qcom: Fix use-after-free on unbind Lukas Wunner
2020-11-16  8:23 ` [PATCH for-5.10] spi: spi-qcom-qspi: " Lukas Wunner
2020-11-16  8:23 ` [PATCH for-5.10] spi: spi-sh: " Lukas Wunner
2020-11-16  8:23 ` [PATCH for-5.10] spi: pxa2xx: " Lukas Wunner
2020-11-16  8:23 ` [PATCH for-5.10] spi: rpc-if: " Lukas Wunner
2020-11-28 20:20   ` Sergey Shtylyov
2020-11-29 11:35     ` Lukas Wunner
2020-11-30 19:18       ` Sergey Shtylyov
2020-12-02 11:43         ` Lukas Wunner
2020-11-16  8:23 ` [PATCH for-5.10] spi: mxic: Don't leak SPI master in probe error path Lukas Wunner
2020-11-16  8:23 ` [PATCH for-5.10] spi: mt7621: " Lukas Wunner
2020-11-16 11:05   ` Stefan Roese
2020-11-16  8:23 ` [PATCH for-5.10] spi: spi-mtk-nor: " Lukas Wunner
2020-11-17  4:02   ` Ikjoon Jang [this message]
2020-11-17 12:32   ` Mark Brown
2020-11-16  8:23 ` [PATCH for-5.10] spi: gpio: " Lukas Wunner
2020-11-16 19:23   ` Andrey Smirnov
2020-11-16 23:03     ` Lukas Wunner
2020-11-16 23:59       ` Andrey Smirnov
2020-11-18  1:08   ` Linus Walleij
2020-11-16  8:23 ` [PATCH for-5.10] spi: npcm-fiu: " Lukas Wunner
2020-11-17 22:38   ` Mark Brown
2020-12-01 13:57   ` Mark Brown
2020-12-01 14:30     ` Lukas Wunner
2020-12-01 17:17       ` Mark Brown
2020-12-01 17:49         ` Lukas Wunner
2020-12-02 15:17           ` Mark Brown
2020-11-16  8:23 ` [PATCH for-5.10] spi: rb4xx: " Lukas Wunner
2020-11-16  8:23 ` [PATCH for-5.10] spi: sc18is602: " Lukas Wunner
2020-11-16  8:23 ` [PATCH for-5.10] media: netup_unidvb: " Lukas Wunner
2020-11-23 14:06   ` Mauro Carvalho Chehab
2020-12-01 13:57   ` Mark Brown

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=CAATdQgDi_AfRvQ5Qe9yjU5xZHPm3CcVXyAd5EX4M824sg4ZDtw@mail.gmail.com \
    --to=ikjn@chromium.org \
    --cc=broonie@kernel.org \
    --cc=gch981213@gmail.com \
    --cc=linux-spi@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=matthias.bgg@gmail.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

Linux-SPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-spi/0 linux-spi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-spi linux-spi/ https://lore.kernel.org/linux-spi \
		linux-spi@vger.kernel.org
	public-inbox-index linux-spi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-spi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git