89b66956e08162d98aa8c3429ae467afa4538494
[openwrt/staging/chunkeey.git] /
1 From 0960432c8261efb05bcf5ba6d8fe13c8293086a9 Mon Sep 17 00:00:00 2001
2 From: Colin Ian King <colin.king@canonical.com>
3 Date: Mon, 16 Dec 2019 16:10:59 +0000
4 Subject: [PATCH] dma-buf: fix resource leak on -ENOTTY error return
5 path
6
7 Commit f9d3b2c600075d1f79efcd5cdb1718c2f554c0f9 upstream.
8
9 The -ENOTTY error return path does not free the allocated
10 kdata as it returns directly. Fix this by returning via the
11 error handling label err.
12
13 Addresses-Coverity: ("Resource leak")
14 Fixes: c02a81fba74f ("dma-buf: Add dma-buf heaps framework")
15 Signed-off-by: Colin Ian King <colin.king@canonical.com>
16 Acked-by: John Stultz <john.stultz@linaro.org>
17 Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
18 Link: https://patchwork.freedesktop.org/patch/msgid/20191216161059.269492-1-colin.king@canonical.com
19 ---
20 drivers/dma-buf/dma-heap.c | 3 ++-
21 1 file changed, 2 insertions(+), 1 deletion(-)
22
23 --- a/drivers/dma-buf/dma-heap.c
24 +++ b/drivers/dma-buf/dma-heap.c
25 @@ -157,7 +157,8 @@ static long dma_heap_ioctl(struct file *
26 ret = dma_heap_ioctl_allocate(file, kdata);
27 break;
28 default:
29 - return -ENOTTY;
30 + ret = -ENOTTY;
31 + goto err;
32 }
33
34 if (copy_to_user((void __user *)arg, kdata, out_size) != 0)