From: Tony Battersby <tonyb@cybernetics.com>
To: linux-scsi@vger.kernel.org,
"James E.J. Bottomley" <JBottomley@parallels.com>,
Christoph Hellwig <hch@infradead.org>,
Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] blk-mq: fix double-free in error path
Date: Wed, 11 Feb 2015 11:32:30 -0500 [thread overview]
Message-ID: <54DB841E.6030108@cybernetics.com> (raw)
If the allocation of bt->bs fails, then bt->map can be freed twice, once
in blk_mq_init_bitmap_tags() -> bt_alloc(), and once in
blk_mq_init_bitmap_tags() -> bt_free(). Fix by setting the pointer to
NULL after the first free.
Cc: <stable@vger.kernel.org>
Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
---
For inclusion in kernel 3.20.
--- linux-3.19.0/block/blk-mq-tag.c.orig 2015-02-08 21:54:22.000000000 -0500
+++ linux-3.19.0/block/blk-mq-tag.c 2015-02-10 09:42:38.000000000 -0500
@@ -509,6 +509,7 @@ static int bt_alloc(struct blk_mq_bitmap
bt->bs = kzalloc(BT_WAIT_QUEUES * sizeof(*bt->bs), GFP_KERNEL);
if (!bt->bs) {
kfree(bt->map);
+ bt->map = NULL;
return -ENOMEM;
}
next reply other threads:[~2015-02-11 16:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-11 16:32 Tony Battersby [this message]
2015-02-11 16:43 ` [PATCH] blk-mq: fix double-free in error path Jens Axboe
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=54DB841E.6030108@cybernetics.com \
--to=tonyb@cybernetics.com \
--cc=JBottomley@parallels.com \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.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).