re: dmaengine: jz4780: add driver for the Ingenic JZ4780 DMA controller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Alex Smith,

The patch d894fc6046fe: "dmaengine: jz4780: add driver for the
Ingenic JZ4780 DMA controller" from Mar 18, 2015, leads to the
following static checker warning:

	drivers/dma/dma-jz4780.c:400 jz4780_dma_prep_dma_memcpy()
	warn: unsigned 'tsz' is never less than zero.

drivers/dma/dma-jz4780.c
   386  struct dma_async_tx_descriptor *jz4780_dma_prep_dma_memcpy(
   387          struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
   388          size_t len, unsigned long flags)
   389  {
   390          struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan);
   391          struct jz4780_dma_desc *desc;
   392          uint32_t tsz;
   393          int ord;
   394  
   395          desc = jz4780_dma_desc_alloc(jzchan, 1, DMA_MEMCPY);
   396          if (!desc)
   397                  return NULL;
   398  
   399          tsz = jz4780_dma_transfer_size(dest | src | len, &ord);
   400          if (tsz < 0)
   401                  return ERR_PTR(tsz);

This code has unsigned leprosy.  If you do a search for uint32_t you
will uncover several other mistakes.  Also this function should be
returning NULL on error instead of "ERR_PTR(tsz)" or it leads to an
Oops.

   402  
   403          desc->desc[0].dsa = src;
   404          desc->desc[0].dta = dest;
   405          desc->desc[0].drt = JZ_DMA_DRT_AUTO;
   406          desc->desc[0].dcm = JZ_DMA_DCM_TIE | JZ_DMA_DCM_SAI | JZ_DMA_DCM_DAI |
   407                              tsz << JZ_DMA_DCM_TSZ_SHIFT |
   408                              JZ_DMA_WIDTH_32_BIT << JZ_DMA_DCM_SP_SHIFT |
   409                              JZ_DMA_WIDTH_32_BIT << JZ_DMA_DCM_DP_SHIFT;
   410          desc->desc[0].dtc = len >> ord;
   411  
   412          return vchan_tx_prep(&jzchan->vchan, &desc->vdesc, flags);
   413  }

Other static checker warnings:
drivers/dma/dma-jz4780.c:747 jz4780_dma_probe() warn: unsigned 'jzdma->irq' is never less than zero.
drivers/dma/dma-jz4780.c:748 jz4780_dma_probe() warn: passing uninitialized 'ret'

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




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux