From: Gerald Schaefer <gerald.schaefer@de.ibm.com>
To: Dan Williams <dan.j.williams@intel.com>, Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
Gerald Schaefer <gerald.schaefer@de.ibm.com>
Subject: [PATCH] brd: fix uninitialized use of brd->dax_dev
Date: Wed, 3 May 2017 14:56:02 +0200 [thread overview]
Message-ID: <20170503125602.26956-1-gerald.schaefer@de.ibm.com> (raw)
commit 1647b9b9 "brd: add dax_operations support" introduced the allocation
and freeing of a dax_device, but the allocated dax_device is not stored
into the brd_device, so brd_del_one() will eventually operate on an
uninitialized brd->dax_dev.
Fix this by storing the allocated dax_device to brd->dax_dev.
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
---
drivers/block/brd.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 38f38df..57b574f 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -404,9 +404,7 @@ static struct brd_device *brd_alloc(int i)
{
struct brd_device *brd;
struct gendisk *disk;
-#ifdef CONFIG_BLK_DEV_RAM_DAX
- struct dax_device *dax_dev;
-#endif
+
brd = kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd)
goto out;
@@ -443,8 +441,8 @@ static struct brd_device *brd_alloc(int i)
#ifdef CONFIG_BLK_DEV_RAM_DAX
queue_flag_set_unlocked(QUEUE_FLAG_DAX, brd->brd_queue);
- dax_dev = alloc_dax(brd, disk->disk_name, &brd_dax_ops);
- if (!dax_dev)
+ brd->dax_dev = alloc_dax(brd, disk->disk_name, &brd_dax_ops);
+ if (!brd->dax_dev)
goto out_free_inode;
#endif
@@ -453,8 +451,8 @@ static struct brd_device *brd_alloc(int i)
#ifdef CONFIG_BLK_DEV_RAM_DAX
out_free_inode:
- kill_dax(dax_dev);
- put_dax(dax_dev);
+ kill_dax(brd->dax_dev);
+ put_dax(brd->dax_dev);
#endif
out_free_queue:
blk_cleanup_queue(brd->brd_queue);
--
2.10.2
next reply other threads:[~2017-05-03 12:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 12:56 Gerald Schaefer [this message]
2017-05-03 18:44 ` [PATCH] brd: fix uninitialized use of brd->dax_dev Dan Williams
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=20170503125602.26956-1-gerald.schaefer@de.ibm.com \
--to=gerald.schaefer@de.ibm.com \
--cc=axboe@kernel.dk \
--cc=dan.j.williams@intel.com \
--cc=linux-block@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.