Skip to content

Commit b52e28e

Browse files
nxpfranklivinodkoul
authored andcommitted
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: 6aa60f7 ("dmaengine: fsl-edma: add safety check for 'srcid'") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/r/202404110915.riwV3ZAC-lkp@intel.com/ Signed-off-by: Frank Li <Frank.Li@nxp.com> Link: https://lore.kernel.org/r/20240411203935.3137158-1-Frank.Li@nxp.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 4665be0 commit b52e28e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drivers/dma/fsl-edma-common.c

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Copyright (c) 2013-2014 Freescale Semiconductor, Inc
44
// Copyright (c) 2017 Sysam, Angelo Dureghello <angelo@sysam.it>
55

6+
#include <linux/cleanup.h>
67
#include <linux/clk.h>
78
#include <linux/dmapool.h>
89
#include <linux/module.h>

drivers/dma/fsl-edma-main.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
105105
if (dma_spec->args_count != 2)
106106
return NULL;
107107

108-
mutex_lock(&fsl_edma->fsl_edma_mutex);
108+
guard(mutex)(&fsl_edma->fsl_edma_mutex);
109+
109110
list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, device_node) {
110111
if (chan->client_count)
111112
continue;
@@ -124,12 +125,10 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
124125

125126
fsl_edma_chan_mux(fsl_chan, fsl_chan->srcid,
126127
true);
127-
mutex_unlock(&fsl_edma->fsl_edma_mutex);
128128
return chan;
129129
}
130130
}
131131
}
132-
mutex_unlock(&fsl_edma->fsl_edma_mutex);
133132
return NULL;
134133
}
135134

0 commit comments

Comments
 (0)