From: Robert Elliott <elliott@hp.com>
To: axboe@kernel.dk, abhijit.mahajan@avagotech.com,
kmo@datarainc.com, nagalakshmi.nandigama@avagotech.com,
asamymuthupa@micron.com, snitzer@redhat.com,
JBottomley@parallels.com, relliott@beardog.cce.hp.com,
sreekanth.reddy@avagotech.com,
praveen.krishnamoorthy@avagotech.com, agordeev@redhat.com,
scameron@beardog.cce.hp.com, tom.leiming@gmail.com,
elliott@hp.com, sbradshaw@micron.com, hch@lst.de, m@bjorling.me
Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: [PATCH 1/3] blk-mq: cleanup after blk_mq_init_rq_map failures
Date: Thu, 17 Jul 2014 14:39:09 -0500 [thread overview]
Message-ID: <20140717193904.1924.84206.stgit@beardog.cce.hp.com> (raw)
In-Reply-To: <20140717193707.1924.87867.stgit@beardog.cce.hp.com>
In blk-mq.c blk_mq_alloc_tag_set, if:
set->tags = kmalloc_node()
succeeds, but one of the blk_mq_init_rq_map() calls fails,
goto out_unwind;
needs to free set->tags so the caller is not obligated
to do so. None of the current callers (null_blk,
virtio_blk, virtio_blk, or the forthcoming scsi-mq)
do so.
set->tags needs to be set to NULL after doing so,
so other tag cleanup logic doesn't try to free
a stale pointer later. Also set it to NULL
in blk_mq_free_tag_set.
Tested with error injection on the forthcoming
scsi-mq + hpsa combination.
Signed-off-by: Robert Elliott <elliott@hp.com>
---
block/blk-mq.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ad69ef6..4a24b97 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1996,6 +1996,8 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
out_unwind:
while (--i >= 0)
blk_mq_free_rq_map(set, set->tags[i], i);
+ kfree(set->tags);
+ set->tags = NULL;
out:
return -ENOMEM;
}
@@ -2011,6 +2013,7 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)
}
kfree(set->tags);
+ set->tags = NULL;
}
EXPORT_SYMBOL(blk_mq_free_tag_set);
next prev parent reply other threads:[~2014-07-17 19:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-17 19:38 [PATCH 0/3] blk-mq: blk_mq_init_rq_map error handling Robert Elliott
2014-07-17 19:39 ` Robert Elliott [this message]
2014-07-18 9:45 ` [PATCH 1/3] blk-mq: cleanup after blk_mq_init_rq_map failures Christoph Hellwig
2014-07-17 19:39 ` [PATCH 2/3] blk-mq: pass along blk_mq_alloc_tag_set return values Robert Elliott
2014-07-18 9:45 ` Christoph Hellwig
2014-07-17 19:39 ` [PATCH 3/3] mpt3sas, mpt2sas: fix scsi_add_host error handling problems in _scsih_probe Robert Elliott
2014-07-18 9:46 ` Christoph Hellwig
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=20140717193904.1924.84206.stgit@beardog.cce.hp.com \
--to=elliott@hp.com \
--cc=JBottomley@parallels.com \
--cc=abhijit.mahajan@avagotech.com \
--cc=agordeev@redhat.com \
--cc=asamymuthupa@micron.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kmo@datarainc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=m@bjorling.me \
--cc=nagalakshmi.nandigama@avagotech.com \
--cc=praveen.krishnamoorthy@avagotech.com \
--cc=relliott@beardog.cce.hp.com \
--cc=sbradshaw@micron.com \
--cc=scameron@beardog.cce.hp.com \
--cc=snitzer@redhat.com \
--cc=sreekanth.reddy@avagotech.com \
--cc=tom.leiming@gmail.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).