dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x
PATCH 1/1 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.
---
drivers/dma/amba-pl08x.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/dma/amba-pl08x.c +9 -1
@@ -92,6 +92,8 @@#define DRIVER_NAME "pl08xdmac" +static struct amba_driver pl08x_amba_driver; +/** * struct vendor_data - vendor-specific config parameters for PL08x derivatives * @channels: the number of channels available in this variant
@@ -1489,9 +1491,15 @@ static int pl08x_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,bool pl08x_filter_id (struct dma_chan *chan,void *chan_id) { -struct pl08x_dma_chan *plchan =to_pl08x_chan (chan); +struct pl08x_dma_chan *plchan;char *name = chan_id; +/* Reject channels for devices not bound to this driver */ +if (chan->device->dev->driver != &pl08x_amba_driver.drv) +return false; + + plchan =to_pl08x_chan (chan); +/* Check that the channel is not taken! */ if (!strcmp (plchan->name, name))return true;
PATCH 1/1 dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x
2011/8/31 Russell King - ARM Linux <[email protected]>:
Quoted 20 lines
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 <[email protected]>---
?drivers/dma/amba-pl08x.c | ? 10 +++++++++-
?1 files changed, 9 insertions(+), 1 deletions(-)drivers/dma/amba-pl08x.c +0
-0@@ -92,6 +92,8 @@?#define
DRIVER_NAME? ?"pl08xdmac"
drivers/dma/amba-pl08x.c line 96
Quoted 2 lines
drivers/dma/amba-pl08x.c +2
-0+static struct amba_driver pl08x_amba_driver; +
This will make C++ coders confused a bit. Valid C, though.
Best Regards,
Micha? Miros?aw
Vinod Koul
AppliedPATCH 1/1 dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x
In reply to Russell King - ARM LinuxQuoted 8 lines · Russell King - ARM Linux
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 <[email protected]>
Applied, Thanks
Signature · 1 line
~Vinod
PATCH 1/1 dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x
In reply to Michał Mirosław2011/8/31 Micha? Miros?aw <[email protected]>:
Quoted 5 lines
2011/8/31 Russell King - ARM Linux <[email protected]>:
drivers/dma/amba-pl08x.c line 96
Quoted 2 lines
drivers/dma/amba-pl08x.c +2
-0+static struct amba_driver pl08x_amba_driver; +This will make C++ coders confused a bit. Valid C, though.
We do this kind of forward declarations all over the kernel if that's what you mean. (I cannot claim to know C++ well enough to grasp if that's the potential confusion...)
Yours,
Linus Walleij