dmatest: prevent memory leakage on error path in thread
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 22 Aug 2014 12:19:44 +0000 (15:19 +0300)
committerDan Williams <dan.j.williams@intel.com>
Fri, 22 Aug 2014 13:17:37 +0000 (06:17 -0700)
When we fail to allocate memory for thread->srcs or thread->dsts and src_cnt or
dst_cnt great than 1 we leak memory on error path. This patch fixes the issue.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/dma/dmatest.c

index 05b6dea770a407fc94e614b82bdbdf0ef0212593..69616e2108fc312d17172ac5b15851cda59ca662 100644 (file)
@@ -688,14 +688,14 @@ static int dmatest_func(void *data)
        runtime = ktime_us_delta(ktime_get(), ktime);
 
        ret = 0;
+err_dstbuf:
        for (i = 0; thread->dsts[i]; i++)
                kfree(thread->dsts[i]);
-err_dstbuf:
        kfree(thread->dsts);
 err_dsts:
+err_srcbuf:
        for (i = 0; thread->srcs[i]; i++)
                kfree(thread->srcs[i]);
-err_srcbuf:
        kfree(thread->srcs);
 err_srcs:
        kfree(pq_coefs);