From: Colin King <colin.king@canonical.com>
To: Sumit Semwal <sumit.semwal@linaro.org>,
"Andrew F . Davis" <afd@ti.com>,
Benjamin Gaignard <benjamin.gaignard@linaro.org>,
Liam Mark <lmark@codeaurora.org>,
Laura Abbott <labbott@redhat.com>,
Brian Starkey <brian.starkey@arm.com>,
John Stultz <john.stultz@linaro.org>,
Sandeep Patil <sspatil@android.com>,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] dma-buf: fix resource leak on -ENOTTY error return path
Date: Mon, 16 Dec 2019 16:10:59 +0000 [thread overview]
Message-ID: <20191216161059.269492-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
The -ENOTTY error return path does not free the allocated
kdata as it returns directly. Fix this by returning via the
error handling label err.
Addresses-Coverity: ("Resource leak")
Fixes: c02a81fba74f ("dma-buf: Add dma-buf heaps framework")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/dma-buf/dma-heap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
index 4f04d104ae61..80f2f5eac1e4 100644
--- a/drivers/dma-buf/dma-heap.c
+++ b/drivers/dma-buf/dma-heap.c
@@ -157,7 +157,8 @@ static long dma_heap_ioctl(struct file *file, unsigned int ucmd,
ret = dma_heap_ioctl_allocate(file, kdata);
break;
default:
- return -ENOTTY;
+ ret = -ENOTTY;
+ goto err;
}
if (copy_to_user((void __user *)arg, kdata, out_size) != 0)
--
2.24.0
next reply other threads:[~2019-12-16 16:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 16:10 Colin King [this message]
2019-12-16 21:07 ` [PATCH][next] dma-buf: fix resource leak on -ENOTTY error return path John Stultz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191216161059.269492-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=afd@ti.com \
--cc=benjamin.gaignard@linaro.org \
--cc=brian.starkey@arm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=john.stultz@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=labbott@redhat.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=lmark@codeaurora.org \
--cc=sspatil@android.com \
--cc=sumit.semwal@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).