From: sultan@kerneltoast.com
Cc: Sultan Alsawaf <sultan@kerneltoast.com>,
Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@redhat.com>,
dm-devel@redhat.com, linux-kernel@vger.kernel.org
Subject: [PATCH] dm crypt: fix memory leak in dm_crypt_integrity_io_alloc() error path
Date: Sat, 16 Feb 2019 13:00:22 -0800 [thread overview]
Message-ID: <20190216210022.29483-1-sultan@kerneltoast.com> (raw)
From: Sultan Alsawaf <sultan@kerneltoast.com>
dm_crypt_integrity_io_alloc() allocates space for an integrity payload but
doesn't free it in the error path, leaking memory. Add a bio_integrity_free()
invocation upon error to fix the memory leak.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
---
drivers/md/dm-crypt.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index dd538e6b2..f731e1fe0 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -939,8 +939,10 @@ static int dm_crypt_integrity_io_alloc(struct dm_crypt_io *io, struct bio *bio)
ret = bio_integrity_add_page(bio, virt_to_page(io->integrity_metadata),
tag_len, offset_in_page(io->integrity_metadata));
- if (unlikely(ret != tag_len))
+ if (unlikely(ret != tag_len)) {
+ bio_integrity_free(bio);
return -ENOMEM;
+ }
return 0;
}
--
2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: sultan@kerneltoast.com
To: unlisted-recipients:; (no To-header on input)
Cc: Sultan Alsawaf <sultan@kerneltoast.com>,
Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@redhat.com>,
dm-devel@redhat.com, linux-kernel@vger.kernel.org
Subject: [PATCH] dm crypt: fix memory leak in dm_crypt_integrity_io_alloc() error path
Date: Sat, 16 Feb 2019 13:00:22 -0800 [thread overview]
Message-ID: <20190216210022.29483-1-sultan@kerneltoast.com> (raw)
From: Sultan Alsawaf <sultan@kerneltoast.com>
dm_crypt_integrity_io_alloc() allocates space for an integrity payload but
doesn't free it in the error path, leaking memory. Add a bio_integrity_free()
invocation upon error to fix the memory leak.
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
---
drivers/md/dm-crypt.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index dd538e6b2..f731e1fe0 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -939,8 +939,10 @@ static int dm_crypt_integrity_io_alloc(struct dm_crypt_io *io, struct bio *bio)
ret = bio_integrity_add_page(bio, virt_to_page(io->integrity_metadata),
tag_len, offset_in_page(io->integrity_metadata));
- if (unlikely(ret != tag_len))
+ if (unlikely(ret != tag_len)) {
+ bio_integrity_free(bio);
return -ENOMEM;
+ }
return 0;
}
--
2.20.1
next reply other threads:[~2019-02-16 21:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-16 21:00 sultan [this message]
2019-02-16 21:00 ` [PATCH] dm crypt: fix memory leak in dm_crypt_integrity_io_alloc() error path sultan
2019-02-22 22:45 ` Mike Snitzer
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=20190216210022.29483-1-sultan@kerneltoast.com \
--to=sultan@kerneltoast.com \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=snitzer@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.