[PATCH] fs/iomap: fix memory leak on error condition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux