linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] dmatest: Fix NULL pointer dereference on ioat
@ 2012-11-11 23:03 Jon Mason
  2012-11-14  2:47 ` viresh kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Jon Mason @ 2012-11-11 23:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dave Jiang, Vinod Koul, Dan Williams

device_control is an optional and not implemented in all DMA drivers.
Any calls to these will result in a NULL pointer dereference.  dmatest
makes two of these calls when completing the kernel thread and removing
the module.  These are corrected by calling the dmaengine_device_control
wrapper and checking for a non-existant device_control function pointer
there.

Signed-off-by: Jon Mason <jon.mason@intel.com>
CC: Vinod Koul <vinod.koul@intel.com>
CC: Dan Williams <djbw@fb.com>
---
 drivers/dma/dmatest.c     |    4 ++--
 include/linux/dmaengine.h |    5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 24225f0..6ef9465 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -499,7 +499,7 @@ err_srcs:
 			thread_name, total_tests, failed_tests, ret);
 
 	/* terminate all transfers on specified channels */
-	chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
+	dmaengine_terminate_all(chan);
 	if (iterations > 0)
 		while (!kthread_should_stop()) {
 			DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wait_dmatest_exit);
@@ -524,7 +524,7 @@ static void dmatest_cleanup_channel(struct dmatest_chan *dtc)
 	}
 
 	/* terminate all transfers on specified channels */
-	dtc->chan->device->device_control(dtc->chan, DMA_TERMINATE_ALL, 0);
+	dmaengine_terminate_all(dtc->chan);
 
 	kfree(dtc);
 }
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index d3201e4..cf94e5f 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -608,7 +608,10 @@ static inline int dmaengine_device_control(struct dma_chan *chan,
 					   enum dma_ctrl_cmd cmd,
 					   unsigned long arg)
 {
-	return chan->device->device_control(chan, cmd, arg);
+	if (chan->device->device_control)
+		return chan->device->device_control(chan, cmd, arg);
+	else
+		return -ENOSYS;
 }
 
 static inline int dmaengine_slave_config(struct dma_chan *chan,
-- 
1.7.9.5


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

* Re: [PATCH v2] dmatest: Fix NULL pointer dereference on ioat
  2012-11-11 23:03 [PATCH v2] dmatest: Fix NULL pointer dereference on ioat Jon Mason
@ 2012-11-14  2:47 ` viresh kumar
  2012-11-22  5:25   ` viresh kumar
  0 siblings, 1 reply; 4+ messages in thread
From: viresh kumar @ 2012-11-14  2:47 UTC (permalink / raw)
  To: Jon Mason; +Cc: linux-kernel, Dave Jiang, Vinod Koul, Dan Williams

On Mon, Nov 12, 2012 at 4:33 AM, Jon Mason <jon.mason@intel.com> wrote:
> device_control is an optional and not implemented in all DMA drivers.
> Any calls to these will result in a NULL pointer dereference.  dmatest
> makes two of these calls when completing the kernel thread and removing
> the module.  These are corrected by calling the dmaengine_device_control
> wrapper and checking for a non-existant device_control function pointer
> there.
>
> Signed-off-by: Jon Mason <jon.mason@intel.com>
> CC: Vinod Koul <vinod.koul@intel.com>
> CC: Dan Williams <djbw@fb.com>
> ---
>  drivers/dma/dmatest.c     |    4 ++--
>  include/linux/dmaengine.h |    5 ++++-
>  2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
> index 24225f0..6ef9465 100644
> --- a/drivers/dma/dmatest.c
> +++ b/drivers/dma/dmatest.c
> @@ -499,7 +499,7 @@ err_srcs:
>                         thread_name, total_tests, failed_tests, ret);
>
>         /* terminate all transfers on specified channels */
> -       chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
> +       dmaengine_terminate_all(chan);
>         if (iterations > 0)
>                 while (!kthread_should_stop()) {
>                         DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wait_dmatest_exit);
> @@ -524,7 +524,7 @@ static void dmatest_cleanup_channel(struct dmatest_chan *dtc)
>         }
>
>         /* terminate all transfers on specified channels */
> -       dtc->chan->device->device_control(dtc->chan, DMA_TERMINATE_ALL, 0);
> +       dmaengine_terminate_all(dtc->chan);
>
>         kfree(dtc);
>  }
> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> index d3201e4..cf94e5f 100644
> --- a/include/linux/dmaengine.h
> +++ b/include/linux/dmaengine.h
> @@ -608,7 +608,10 @@ static inline int dmaengine_device_control(struct dma_chan *chan,
>                                            enum dma_ctrl_cmd cmd,
>                                            unsigned long arg)
>  {
> -       return chan->device->device_control(chan, cmd, arg);
> +       if (chan->device->device_control)
> +               return chan->device->device_control(chan, cmd, arg);
> +       else
> +               return -ENOSYS;
>  }

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>

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

* Re: [PATCH v2] dmatest: Fix NULL pointer dereference on ioat
  2012-11-14  2:47 ` viresh kumar
@ 2012-11-22  5:25   ` viresh kumar
  2012-12-03 17:42     ` Koul, Vinod
  0 siblings, 1 reply; 4+ messages in thread
From: viresh kumar @ 2012-11-22  5:25 UTC (permalink / raw)
  To: Vinod Koul, Dan Williams; +Cc: linux-kernel, Dave Jiang, Jon Mason

On Wed, Nov 14, 2012 at 8:17 AM, viresh kumar <viresh.kumar@linaro.org> wrote:
> On Mon, Nov 12, 2012 at 4:33 AM, Jon Mason <jon.mason@intel.com> wrote:
>> device_control is an optional and not implemented in all DMA drivers.
>> Any calls to these will result in a NULL pointer dereference.  dmatest
>> makes two of these calls when completing the kernel thread and removing
>> the module.  These are corrected by calling the dmaengine_device_control
>> wrapper and checking for a non-existant device_control function pointer
>> there.
>>
>> Signed-off-by: Jon Mason <jon.mason@intel.com>
>> CC: Vinod Koul <vinod.koul@intel.com>
>> CC: Dan Williams <djbw@fb.com>

> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>

Vinod/Dan: I couldn't find this patch and
https://patchwork.kernel.org/patch/1720971/
in you trees. Are you pushing them for 3.8?

--
viresh

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

* RE: [PATCH v2] dmatest: Fix NULL pointer dereference on ioat
  2012-11-22  5:25   ` viresh kumar
@ 2012-12-03 17:42     ` Koul, Vinod
  0 siblings, 0 replies; 4+ messages in thread
From: Koul, Vinod @ 2012-12-03 17:42 UTC (permalink / raw)
  To: viresh kumar, Dan Williams; +Cc: linux-kernel, Jiang, Dave, Mason, Jon

> On Wed, Nov 14, 2012 at 8:17 AM, viresh kumar <viresh.kumar@linaro.org> wrote:
> > On Mon, Nov 12, 2012 at 4:33 AM, Jon Mason <jon.mason@intel.com> wrote:
> >> device_control is an optional and not implemented in all DMA drivers.
> >> Any calls to these will result in a NULL pointer dereference.
> >> dmatest makes two of these calls when completing the kernel thread
> >> and removing the module.  These are corrected by calling the
> >> dmaengine_device_control wrapper and checking for a non-existant
> >> device_control function pointer there.
> >>
> >> Signed-off-by: Jon Mason <jon.mason@intel.com>
> >> CC: Vinod Koul <vinod.koul@intel.com>
> >> CC: Dan Williams <djbw@fb.com>
> 
> > Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Applied, Thanks

--
~Vinod

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

end of thread, other threads:[~2012-12-03 17:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-11 23:03 [PATCH v2] dmatest: Fix NULL pointer dereference on ioat Jon Mason
2012-11-14  2:47 ` viresh kumar
2012-11-22  5:25   ` viresh kumar
2012-12-03 17:42     ` Koul, Vinod

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).