Skip to content

Commit 4c325ef

Browse files
committed
misc: rp1-pio: Fix a config_xfer error path
If the DMA channel allocation fails, the relevant dma_configs entry should be marked as no longer claimed, otherwise rp1_pio_sm_dma_free will be called with an error number as a DMA channel pointer. Signed-off-by: Phil Elwell <[email protected]>
1 parent 11d5d0d commit 4c325ef

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/misc/rp1-pio.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,10 @@ static int rp1_pio_sm_config_xfer_internal(struct rp1_pio_client *client, uint s
648648
chan_name[3] = '\0';
649649

650650
dma->chan = dma_request_chan(dev, chan_name);
651-
if (IS_ERR(dma->chan))
652-
return PTR_ERR(dma->chan);
651+
if (IS_ERR(dma->chan)) {
652+
ret = PTR_ERR(dma->chan);
653+
goto err_unclaim;
654+
}
653655

654656
/* Alloc and map bounce buffers */
655657
for (dma->buf_count = 0; dma->buf_count < buf_count; dma->buf_count++) {
@@ -694,6 +696,7 @@ static int rp1_pio_sm_config_xfer_internal(struct rp1_pio_client *client, uint s
694696
err_dma_free:
695697
rp1_pio_sm_dma_free(dev, dma);
696698

699+
err_unclaim:
697700
spin_lock(&pio->lock);
698701
client->claimed_dmas &= ~dma_mask;
699702
pio->claimed_dmas &= ~dma_mask;

0 commit comments

Comments
 (0)