Commit b52e28ec authored by Frank Li's avatar Frank Li Committed by Vinod Koul

dmaengine: fsl-edma: fix miss mutex unlock at an error return path

Use cleanup to manage mutex. Let compiler to do scope guard automatically.

Fixes: 6aa60f79 ("dmaengine: fsl-edma: add safety check for 'srcid'")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202404110915.riwV3ZAC-lkp@intel.com/Signed-off-by: default avatarFrank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20240411203935.3137158-1-Frank.Li@nxp.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 4665be0e
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// Copyright (c) 2013-2014 Freescale Semiconductor, Inc // Copyright (c) 2013-2014 Freescale Semiconductor, Inc
// Copyright (c) 2017 Sysam, Angelo Dureghello <angelo@sysam.it> // Copyright (c) 2017 Sysam, Angelo Dureghello <angelo@sysam.it>
#include <linux/cleanup.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/dmapool.h> #include <linux/dmapool.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -105,7 +105,8 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec, ...@@ -105,7 +105,8 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
if (dma_spec->args_count != 2) if (dma_spec->args_count != 2)
return NULL; return NULL;
mutex_lock(&fsl_edma->fsl_edma_mutex); guard(mutex)(&fsl_edma->fsl_edma_mutex);
list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, device_node) { list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, device_node) {
if (chan->client_count) if (chan->client_count)
continue; continue;
...@@ -124,12 +125,10 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec, ...@@ -124,12 +125,10 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
fsl_edma_chan_mux(fsl_chan, fsl_chan->srcid, fsl_edma_chan_mux(fsl_chan, fsl_chan->srcid,
true); true);
mutex_unlock(&fsl_edma->fsl_edma_mutex);
return chan; return chan;
} }
} }
} }
mutex_unlock(&fsl_edma->fsl_edma_mutex);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment