Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x
@ 2011-08-31  8:34 Russell King - ARM Linux
  2011-08-31  8:47 ` Michał Mirosław
  2011-09-05 13:30 ` Vinod Koul
  0 siblings, 2 replies; 4+ messages in thread
From: Russell King - ARM Linux @ 2011-08-31  8:34 UTC (permalink / raw)
  To: linux-arm-kernel

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>
--- 
 drivers/dma/amba-pl08x.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index be21e3f..91d4148 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -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;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x
  2011-08-31  8:34 [PATCH] dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x Russell King - ARM Linux
@ 2011-08-31  8:47 ` Michał Mirosław
  2011-09-06  5:28   ` Linus Walleij
  2011-09-05 13:30 ` Vinod Koul
  1 sibling, 1 reply; 4+ messages in thread
From: Michał Mirosław @ 2011-08-31  8:47 UTC (permalink / raw)
  To: linux-arm-kernel

2011/8/31 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> 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>
> ---
> ?drivers/dma/amba-pl08x.c | ? 10 +++++++++-
> ?1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
> index be21e3f..91d4148 100644
> --- a/drivers/dma/amba-pl08x.c
> +++ b/drivers/dma/amba-pl08x.c
> @@ -92,6 +92,8 @@
>
> ?#define DRIVER_NAME ? ?"pl08xdmac"
>
> +static struct amba_driver pl08x_amba_driver;
> +

This will make C++ coders confused a bit. Valid C, though.

Best Regards,
Micha? Miros?aw

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x
  2011-08-31  8:34 [PATCH] dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x Russell King - ARM Linux
  2011-08-31  8:47 ` Michał Mirosław
@ 2011-09-05 13:30 ` Vinod Koul
  1 sibling, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2011-09-05 13:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 2011-08-31 at 09:34 +0100, Russell King - ARM Linux wrote:
> 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>
Applied, Thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x
  2011-08-31  8:47 ` Michał Mirosław
@ 2011-09-06  5:28   ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2011-09-06  5:28 UTC (permalink / raw)
  To: linux-arm-kernel

2011/8/31 Micha? Miros?aw <mirqus@gmail.com>:
> 2011/8/31 Russell King - ARM Linux <linux@arm.linux.org.uk>:
>> +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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-06  5:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-31  8:34 [PATCH] dmaengine: amba-pl08x: make filter check that the channel is owned by pl08x Russell King - ARM Linux
2011-08-31  8:47 ` Michał Mirosław
2011-09-06  5:28   ` Linus Walleij
2011-09-05 13:30 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox