From: Andreas Platschek <andreas.platschek@opentech.at>
To: vinod.koul@intel.com
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
dan.j.williams@intel.com,
Andreas Platschek <andreas.platschek@opentech.at>
Subject: [PATCH v2] dmaengine: fsl-edma: disable clks on all error paths
Date: Wed, 6 Dec 2017 14:50:23 +0100 [thread overview]
Message-ID: <1512568223-13258-1-git-send-email-andreas.platschek@opentech.at> (raw)
Previously enabled clks are only disabled if clk_prepare_enable() fails.
However, there are other error paths were the previously enabled
clocks are not disabled.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Andreas Platschek <andreas.platschek@opentech.at>
---
drivers/dma/fsl-edma.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c
index 6775f2c74e25..9940f2f7039f 100644
--- a/drivers/dma/fsl-edma.c
+++ b/drivers/dma/fsl-edma.c
@@ -878,7 +878,7 @@ static int fsl_edma_probe(struct platform_device *pdev)
struct fsl_edma_chan *fsl_chan;
struct resource *res;
int len, chans;
- int ret, i;
+ int ret, i, j;
ret = of_property_read_u32(np, "dma-channels", &chans);
if (ret) {
@@ -904,12 +904,21 @@ static int fsl_edma_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 1 + i);
fsl_edma->muxbase[i] = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(fsl_edma->muxbase[i]))
+ if (IS_ERR(fsl_edma->muxbase[i])) {
+ /* disable only clks which were enabled on error */
+ for (j = i-1; j >= 0; j--)
+ clk_disable_unprepare(fsl_edma->muxclk[j]);
+
return PTR_ERR(fsl_edma->muxbase[i]);
+ }
sprintf(clkname, "dmamux%d", i);
fsl_edma->muxclk[i] = devm_clk_get(&pdev->dev, clkname);
if (IS_ERR(fsl_edma->muxclk[i])) {
+ /* disable only clks which were enabled on error */
+ for (j = i-1; j >= 0; j--)
+ clk_disable_unprepare(fsl_edma->muxclk[j]);
+
dev_err(&pdev->dev, "Missing DMAMUX block clock.\n");
return PTR_ERR(fsl_edma->muxclk[i]);
}
--
2.11.0
next reply other threads:[~2017-12-06 13:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-06 13:50 Andreas Platschek [this message]
2017-12-13 4:54 ` 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=1512568223-13258-1-git-send-email-andreas.platschek@opentech.at \
--to=andreas.platschek@opentech.at \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vinod.koul@intel.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®