From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
"Elliott, Robert (Server Storage)" <Elliott@hp.com>
Subject: [patch -next] blk-mq: NULL dereference in __blk_mq_alloc_rq_maps()
Date: Sat, 13 Sep 2014 08:09:28 +0000 [thread overview]
Message-ID: <20140913080928.GA6469@mwanda> (raw)
We shouldn't set "set->tags" to NULL here because if we return -ENOMEM
here then we call the function a second time. On the second time
through the loop then the statement:
set->tags[i] = blk_mq_init_rq_map(set, i);
will Oops. Also it is a memory leak and a layering violation. There is
a correct call to kfree(set->tags) in blk_mq_alloc_tag_set().
Fixes: a516440542af ('blk-mq: scale depth and rq map appropriate if low on memory')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 3d863df..7e7ca57 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1961,7 +1961,6 @@ out_unwind:
while (--i >= 0)
blk_mq_free_rq_map(set, set->tags[i], i);
- set->tags = NULL;
return -ENOMEM;
}
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
"Elliott, Robert (Server Storage)" <Elliott@hp.com>
Subject: [patch -next] blk-mq: NULL dereference in __blk_mq_alloc_rq_maps()
Date: Sat, 13 Sep 2014 11:09:28 +0300 [thread overview]
Message-ID: <20140913080928.GA6469@mwanda> (raw)
We shouldn't set "set->tags" to NULL here because if we return -ENOMEM
here then we call the function a second time. On the second time
through the loop then the statement:
set->tags[i] = blk_mq_init_rq_map(set, i);
will Oops. Also it is a memory leak and a layering violation. There is
a correct call to kfree(set->tags) in blk_mq_alloc_tag_set().
Fixes: a516440542af ('blk-mq: scale depth and rq map appropriate if low on memory')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 3d863df..7e7ca57 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1961,7 +1961,6 @@ out_unwind:
while (--i >= 0)
blk_mq_free_rq_map(set, set->tags[i], i);
- set->tags = NULL;
return -ENOMEM;
}
next reply other threads:[~2014-09-13 8:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-13 8:09 Dan Carpenter [this message]
2014-09-13 8:09 ` [patch -next] blk-mq: NULL dereference in __blk_mq_alloc_rq_maps() Dan Carpenter
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=20140913080928.GA6469@mwanda \
--to=dan.carpenter@oracle.com \
--cc=Elliott@hp.com \
--cc=axboe@kernel.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@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 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.