linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function
@ 2014-04-11 11:20 Dan Carpenter
  2014-04-11 11:29 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2014-04-11 11:20 UTC (permalink / raw)
  To: shubhrajyoti-l0cyMroinI0; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

Hello Shubhrajyoti D,

This is a semi-automatic email about new static checker warnings.

The patch d7b4394e780b: "spi: omap2-mcspi: Cleanup the 
omap2_mcspi_txrx_dma function" from Sep 11, 2012, leads to the 
following Smatch complaint:

drivers/spi/spi-omap2-mcspi.c:425 omap2_mcspi_tx_dma()
	 error: we previously assumed 'mcspi_dma->dma_tx' could be null (see line 405)

drivers/spi/spi-omap2-mcspi.c
   404	
   405		if (mcspi_dma->dma_tx) {
                    ^^^^^^^^^^^^^^^^^
Check for NULL.

   406			struct dma_async_tx_descriptor *tx;
   407			struct scatterlist sg;
   408	
   409			dmaengine_slave_config(mcspi_dma->dma_tx, &cfg);
   410	
   411			sg_init_table(&sg, 1);
   412			sg_dma_address(&sg) = xfer->tx_dma;
   413			sg_dma_len(&sg) = xfer->len;
   414	
   415			tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, &sg, 1,
   416			DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
   417			if (tx) {
   418				tx->callback = omap2_mcspi_tx_callback;
   419				tx->callback_param = spi;
   420				dmaengine_submit(tx);
   421			} else {
   422				/* FIXME: fall back to PIO? */
   423			}
   424		}
   425		dma_async_issue_pending(mcspi_dma->dma_tx);
                                        ^^^^^^^^^^^^^^^^^
Dereferenced inside the function call.  Probably it should be moved
inside the if condition.

   426		omap2_mcspi_set_dma_req(spi, 0, 1);
   427	

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread
* re: spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function
@ 2013-11-01 10:32 Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2013-11-01 10:32 UTC (permalink / raw)
  To: shubhrajyoti-l0cyMroinI0; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

Hello Shubhrajyoti D,

This is a semi-automatic email about new static checker warnings.

The patch d7b4394e780b: "spi: omap2-mcspi: Cleanup the 
omap2_mcspi_txrx_dma function" from Sep 11, 2012, leads to the 
following Smatch complaint:

drivers/spi/spi-omap2-mcspi.c:417 omap2_mcspi_tx_dma()
	 error: we previously assumed 'mcspi_dma->dma_tx' could be null (see line 397)

drivers/spi/spi-omap2-mcspi.c
   396	
   397		if (mcspi_dma->dma_tx) {
                    ^^^^^^^^^^^^^^^^^
Existing check.

   398			struct dma_async_tx_descriptor *tx;
   399			struct scatterlist sg;
   400	
   401			dmaengine_slave_config(mcspi_dma->dma_tx, &cfg);
   402	
   403			sg_init_table(&sg, 1);
   404			sg_dma_address(&sg) = xfer->tx_dma;
   405			sg_dma_len(&sg) = xfer->len;
   406	
   407			tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, &sg, 1,
   408			DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
   409			if (tx) {
   410				tx->callback = omap2_mcspi_tx_callback;
   411				tx->callback_param = spi;
   412				dmaengine_submit(tx);
   413			} else {
   414				/* FIXME: fall back to PIO? */
   415			}
   416		}
   417		dma_async_issue_pending(mcspi_dma->dma_tx);
                                        ^^^^^^^^^^^^^^^^^
Patch introduces a new unchecked dereference.

   418		omap2_mcspi_set_dma_req(spi, 0, 1);
   419	

See also:

	drivers/spi/spi-omap2-mcspi.c:477 omap2_mcspi_rx_dma() error:
	    we previously assumed 'mcspi_dma->dma_rx' could be null
	    (see line 452)

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-04-11 11:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-11 11:20 spi: omap2-mcspi: Cleanup the omap2_mcspi_txrx_dma function Dan Carpenter
2014-04-11 11:29 ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2013-11-01 10:32 Dan Carpenter

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