Skip to content

Commit

Permalink
dmatest: Fix NULL pointer dereference on ioat
Browse files Browse the repository at this point in the history
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 <[email protected]>
CC: Vinod Koul <[email protected]>
CC: Dan Williams <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Vinod Koul <[email protected]>
  • Loading branch information
Jon Mason authored and Vinod Koul committed Jan 8, 2013
1 parent e4d43c1 commit 944ea4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drivers/dma/dmatest.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ static int dmatest_func(void *data)
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);
Expand All @@ -561,7 +561,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);
}
Expand Down
5 changes: 4 additions & 1 deletion include/linux/dmaengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 944ea4d

Please sign in to comment.