From: Garry McNulty <garrmcnu@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: viro@zeniv.linux.org.uk, hch@lst.de,
linux-kernel@vger.kernel.org, Garry McNulty <garrmcnu@gmail.com>
Subject: [PATCH] fs/iomap: fix memory leak on error condition
Date: Wed, 21 Feb 2018 20:41:28 +0000 [thread overview]
Message-ID: <20180221204128.5846-1-garrmcnu@gmail.com> (raw)
If the call to is_sync_kiocb() fails an error is returned without
freeing dio. Set the return code and jump to out_free_dio.
Detected by CoverityScan, CID 1429424 ("Resource leak")
Signed-off-by: Garry McNulty <garrmcnu@gmail.com>
---
fs/iomap.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/iomap.c b/fs/iomap.c
index afd163586aa0..65c5db38c15a 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -1063,8 +1063,10 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
iomap_dio_set_error(dio, ret);
if (!atomic_dec_and_test(&dio->ref)) {
- if (!is_sync_kiocb(iocb))
- return -EIOCBQUEUED;
+ if (!is_sync_kiocb(iocb)) {
+ ret = -EIOCBQUEUED;
+ goto out_free_dio;
+ }
for (;;) {
set_current_state(TASK_UNINTERRUPTIBLE);
--
2.14.3
next reply other threads:[~2018-02-21 20:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-21 20:41 Garry McNulty [this message]
2018-02-21 21:56 ` [PATCH] fs/iomap: fix memory leak on error condition Dave Chinner
2018-02-21 23:12 ` Garry McNulty
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=20180221204128.5846-1-garrmcnu@gmail.com \
--to=garrmcnu@gmail.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).