Skip to content

Commit eb9a972

Browse files
dleach02cfriedt
authored andcommitted
driver: edma: Fix MCUX NULL parameter check before dereference
Coverity identified valid error where the routine does a NULL check for two different pointers after they have been dereferenced. fixes #39868 fixes #39874 Signed-off-by: David Leach <[email protected]>
1 parent 4b40dce commit eb9a972

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/dma/dma_mcux_edma.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,18 @@ static void dma_mcux_edma_error_irq_handler(const struct device *dev)
183183
static int dma_mcux_edma_configure(const struct device *dev, uint32_t channel,
184184
struct dma_config *config)
185185
{
186+
/* Check for invalid parameters before dereferencing them. */
187+
if (NULL == dev || NULL == config) {
188+
return -EINVAL;
189+
}
190+
186191
edma_handle_t *p_handle = DEV_EDMA_HANDLE(dev, channel);
187192
struct call_back *data = DEV_CHANNEL_DATA(dev, channel);
188193
struct dma_block_config *block_config = config->head_block;
189194
uint32_t slot = config->dma_slot;
190195
edma_transfer_type_t transfer_type;
191196
int key;
192197

193-
if (NULL == dev || NULL == config) {
194-
return -EINVAL;
195-
}
196-
197198
if (slot > DT_INST_PROP(0, dma_requests)) {
198199
LOG_ERR("source number is outof scope %d", slot);
199200
return -ENOTSUP;

0 commit comments

Comments
 (0)