stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] staging: comedi: das1800: fix possible NULL dereference
       [not found] <1460135700-17749-1-git-send-email-hsweeten@visionengravers.com>
@ 2016-04-08 17:14 ` H Hartley Sweeten
  2016-04-11  9:31   ` Ian Abbott
  0 siblings, 1 reply; 2+ messages in thread
From: H Hartley Sweeten @ 2016-04-08 17:14 UTC (permalink / raw)
  To: devel; +Cc: abbotti, gregkh, H Hartley Sweeten, # 4 . 0+

DMA is optional with this driver. If it was not enabled the devpriv->dma
pointer will be NULL.

Fix the possible NULL pointer dereference when trying to disable the DMA
channels in das1800_ai_cancel() and tidy up the comments to fix the
checkpatch.pl issues:
WARNING: line over 80 characters

It's probably harmless in das1800_ai_setup_dma() because the 'desc' pointer
will not be used if DMA is disabled but fix it there also.

Fixes: 99dfc3357e98 ("staging: comedi: das1800: remove depends on ISA_DMA_API limitation")
Cc: <stable@vger.kernel.org> # 4.0+
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/staging/comedi/drivers/das1800.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index 94078118..3be1096 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -567,14 +567,17 @@ static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 	struct comedi_isadma_desc *desc;
 	int i;
 
-	outb(0x0, dev->iobase + DAS1800_STATUS);	/* disable conversions */
-	outb(0x0, dev->iobase + DAS1800_CONTROL_B);	/* disable interrupts and dma */
-	outb(0x0, dev->iobase + DAS1800_CONTROL_A);	/* disable and clear fifo and stop triggering */
-
-	for (i = 0; i < 2; i++) {
-		desc = &dma->desc[i];
-		if (desc->chan)
-			comedi_isadma_disable(desc->chan);
+	/* disable and stop conversions */
+	outb(0x0, dev->iobase + DAS1800_STATUS);
+	outb(0x0, dev->iobase + DAS1800_CONTROL_B);
+	outb(0x0, dev->iobase + DAS1800_CONTROL_A);
+
+	if (dma) {
+		for (i = 0; i < 2; i++) {
+			desc = &dma->desc[i];
+			if (desc->chan)
+				comedi_isadma_disable(desc->chan);
+		}
 	}
 
 	return 0;
@@ -934,13 +937,14 @@ static void das1800_ai_setup_dma(struct comedi_device *dev,
 {
 	struct das1800_private *devpriv = dev->private;
 	struct comedi_isadma *dma = devpriv->dma;
-	struct comedi_isadma_desc *desc = &dma->desc[0];
+	struct comedi_isadma_desc *desc;
 	unsigned int bytes;
 
 	if ((devpriv->irq_dma_bits & DMA_ENABLED) == 0)
 		return;
 
 	dma->cur_dma = 0;
+	desc = &dma->desc[0];
 
 	/* determine a dma transfer size to fill buffer in 0.3 sec */
 	bytes = das1800_ai_transfer_size(dev, s, desc->maxsize, 300000000);
-- 
2.6.3


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

* Re: [PATCH 1/3] staging: comedi: das1800: fix possible NULL dereference
  2016-04-08 17:14 ` [PATCH 1/3] staging: comedi: das1800: fix possible NULL dereference H Hartley Sweeten
@ 2016-04-11  9:31   ` Ian Abbott
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Abbott @ 2016-04-11  9:31 UTC (permalink / raw)
  To: H Hartley Sweeten, devel; +Cc: gregkh, # 4 . 0+

On 08/04/16 18:14, H Hartley Sweeten wrote:
> DMA is optional with this driver. If it was not enabled the devpriv->dma
> pointer will be NULL.
>
> Fix the possible NULL pointer dereference when trying to disable the DMA
> channels in das1800_ai_cancel() and tidy up the comments to fix the
> checkpatch.pl issues:
> WARNING: line over 80 characters
>
> It's probably harmless in das1800_ai_setup_dma() because the 'desc' pointer
> will not be used if DMA is disabled but fix it there also.
>
> Fixes: 99dfc3357e98 ("staging: comedi: das1800: remove depends on ISA_DMA_API limitation")
> Cc: <stable@vger.kernel.org> # 4.0+
> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
> Cc: Ian Abbott <abbotti@mev.co.uk>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>   drivers/staging/comedi/drivers/das1800.c | 22 +++++++++++++---------
>   1 file changed, 13 insertions(+), 9 deletions(-)
>

Thanks!

Reviewed-by: Ian Abbott <abbotti@mev.co.uk>

(I've already reviewed the other two.)

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-

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

end of thread, other threads:[~2016-04-11  9:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1460135700-17749-1-git-send-email-hsweeten@visionengravers.com>
2016-04-08 17:14 ` [PATCH 1/3] staging: comedi: das1800: fix possible NULL dereference H Hartley Sweeten
2016-04-11  9:31   ` Ian Abbott

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).