diff options
author | Kulikov Vasiliy <segooon@gmail.com> | 2010-07-17 19:19:48 +0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2010-08-04 14:27:47 -0700 |
commit | b9033e682e86f3c6a66763f9b6a3935c5c64e145 (patch) | |
tree | 8aeeb08aeae97b12f0c6cb7338d8cbcf15e6f8ac | |
parent | 556ab45f9a775bfa4762bacc0a4afb5b44b067bc (diff) | |
download | kernel_samsung_smdk4412-b9033e682e86f3c6a66763f9b6a3935c5c64e145.tar.gz kernel_samsung_smdk4412-b9033e682e86f3c6a66763f9b6a3935c5c64e145.tar.bz2 kernel_samsung_smdk4412-b9033e682e86f3c6a66763f9b6a3935c5c64e145.zip |
dma: dmatest: fix potential sign bug
'cnt' is unsigned, so this code may become wrong in future as
dmatest_add_threads() can return error code:
cnt = dmatest_add_threads(dtc, DMA_MEMCPY);
thread_count += cnt > 0 ? cnt : 0;
^^^^^^^
Now it can return only -EINVAL if and only if second argument of
dmatest_add_threads() is not one of DMA_MEMCPY, DMA_XOR, DMA_PQ.
So, now it is not wrong but may become wrong in future.
The semantic patch that finds this problem (many false-positive results):
(http://coccinelle.lip6.fr/)
// <smpl>
@ r1 @
identifier f;
@@
int f(...) { ... }
@@
identifier r1.f;
type T;
unsigned T x;
@@
*x = f(...)
...
*x > 0
Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/dma/dmatest.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 68d58c414cf..5589358b684 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -540,7 +540,7 @@ static int dmatest_add_channel(struct dma_chan *chan) struct dmatest_chan *dtc; struct dma_device *dma_dev = chan->device; unsigned int thread_count = 0; - unsigned int cnt; + int cnt; dtc = kmalloc(sizeof(struct dmatest_chan), GFP_KERNEL); if (!dtc) { |