linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Tony Battersby <tonyb@cybernetics.com>,
	linux-scsi@vger.kernel.org,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	Christoph Hellwig <hch@infradead.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] blk-mq: fix double-free in error path
Date: Wed, 11 Feb 2015 09:43:49 -0700	[thread overview]
Message-ID: <54DB86C5.4090607@kernel.dk> (raw)
In-Reply-To: <54DB841E.6030108@cybernetics.com>

On 02/11/2015 09:32 AM, Tony Battersby wrote:
> 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;
>   	}

Thanks Tony, applied.


-- 
Jens Axboe

      reply	other threads:[~2015-02-11 16:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-11 16:32 [PATCH] blk-mq: fix double-free in error path Tony Battersby
2015-02-11 16:43 ` Jens Axboe [this message]

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=54DB86C5.4090607@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=JBottomley@parallels.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=tonyb@cybernetics.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 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).