From: Paul Cercueil <paul@crapouillou.net>
To: madhuparnabhowmik10@gmail.com
Cc: vkoul@kernel.org, dan.j.williams@intel.com, lars@metafoo.de,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
andrianov@ispras.ru, ldv-project@linuxtesting.org
Subject: Re: [PATCH v2] drivers/dma/dma-jz4780: Fix race condition between probe and irq handler
Date: Fri, 21 Aug 2020 19:01:57 +0200 [thread overview]
Message-ID: <9BBFFQ.4DKVQYU5BDCT1@crapouillou.net> (raw)
In-Reply-To: <20200821034423.12713-1-madhuparnabhowmik10@gmail.com>
Le ven. 21 août 2020 à 9:14, madhuparnabhowmik10@gmail.com a écrit :
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
>
> In probe, IRQ is requested before zchan->id is initialized which can
> be
> read in the irq handler. Hence, shift request irq after other
> initializations
> complete.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Thanks for the patch.
Cheers,
-Paul
>
> ---
> Changes since v1:
> Keep enable clock before request IRQ.
> ---
> drivers/dma/dma-jz4780.c | 38 +++++++++++++++++++-------------------
> 1 file changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
> index 448f663da89c..8beed91428bd 100644
> --- a/drivers/dma/dma-jz4780.c
> +++ b/drivers/dma/dma-jz4780.c
> @@ -879,24 +879,11 @@ static int jz4780_dma_probe(struct
> platform_device *pdev)
> return -EINVAL;
> }
>
> - ret = platform_get_irq(pdev, 0);
> - if (ret < 0)
> - return ret;
> -
> - jzdma->irq = ret;
> -
> - ret = request_irq(jzdma->irq, jz4780_dma_irq_handler, 0,
> dev_name(dev),
> - jzdma);
> - if (ret) {
> - dev_err(dev, "failed to request IRQ %u!\n", jzdma->irq);
> - return ret;
> - }
> -
> jzdma->clk = devm_clk_get(dev, NULL);
> if (IS_ERR(jzdma->clk)) {
> dev_err(dev, "failed to get clock\n");
> ret = PTR_ERR(jzdma->clk);
> - goto err_free_irq;
> + return ret;
> }
>
> clk_prepare_enable(jzdma->clk);
> @@ -949,10 +936,23 @@ static int jz4780_dma_probe(struct
> platform_device *pdev)
> jzchan->vchan.desc_free = jz4780_dma_desc_free;
> }
>
> + ret = platform_get_irq(pdev, 0);
> + if (ret < 0)
> + goto err_disable_clk;
> +
> + jzdma->irq = ret;
> +
> + ret = request_irq(jzdma->irq, jz4780_dma_irq_handler, 0,
> dev_name(dev),
> + jzdma);
> + if (ret) {
> + dev_err(dev, "failed to request IRQ %u!\n", jzdma->irq);
> + goto err_disable_clk;
> + }
> +
> ret = dmaenginem_async_device_register(dd);
> if (ret) {
> dev_err(dev, "failed to register device\n");
> - goto err_disable_clk;
> + goto err_free_irq;
> }
>
> /* Register with OF DMA helpers. */
> @@ -960,17 +960,17 @@ static int jz4780_dma_probe(struct
> platform_device *pdev)
> jzdma);
> if (ret) {
> dev_err(dev, "failed to register OF DMA controller\n");
> - goto err_disable_clk;
> + goto err_free_irq;
> }
>
> dev_info(dev, "JZ4780 DMA controller initialised\n");
> return 0;
>
> -err_disable_clk:
> - clk_disable_unprepare(jzdma->clk);
> -
> err_free_irq:
> free_irq(jzdma->irq, jzdma);
> +
> +err_disable_clk:
> + clk_disable_unprepare(jzdma->clk);
> return ret;
> }
>
> --
> 2.17.1
>
next prev parent reply other threads:[~2020-08-21 17:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-21 3:44 madhuparnabhowmik10
2020-08-21 17:01 ` Paul Cercueil [this message]
2020-08-25 11:15 ` Vinod Koul
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=9BBFFQ.4DKVQYU5BDCT1@crapouillou.net \
--to=paul@crapouillou.net \
--cc=andrianov@ispras.ru \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=ldv-project@linuxtesting.org \
--cc=linux-kernel@vger.kernel.org \
--cc=madhuparnabhowmik10@gmail.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®