Skip to content

Commit 7703eac

Browse files
Russell King - ARM LinuxVinod Koul
authored andcommitted
dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x
Before converting the dma channel to our private data structure, first check that the channel is indeed one which our driver registered. We do this by ensuring that the underlying device is bound to our driver. This avoids potential oopses if we try to reference 'plchan->name' against a foreign drivers dma channel. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
1 parent 503473a commit 7703eac

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎drivers/dma/amba-pl08x.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787

8888
#define DRIVER_NAME "pl08xdmac"
8989

90+
static struct amba_driver pl08x_amba_driver;
91+
9092
/**
9193
* struct vendor_data - vendor-specific config parameters for PL08x derivatives
9294
* @channels: the number of channels available in this variant
@@ -1420,9 +1422,15 @@ static int pl08x_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
14201422

14211423
bool pl08x_filter_id(struct dma_chan *chan, void *chan_id)
14221424
{
1423-
struct pl08x_dma_chan *plchan = to_pl08x_chan(chan);
1425+
struct pl08x_dma_chan *plchan;
14241426
char *name = chan_id;
14251427

1428+
/* Reject channels for devices not bound to this driver */
1429+
if (chan->device->dev->driver != &pl08x_amba_driver.drv)
1430+
return false;
1431+
1432+
plchan = to_pl08x_chan(chan);
1433+
14261434
/* Check that the channel is not taken! */
14271435
if (!strcmp(plchan->name, name))
14281436
return true;

0 commit comments

Comments
 (0)