Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1634966 > unrolled thread

[PATCH] brd: fix uninitialized use of brd->dax_dev

Started byGerald Schaefer <gerald.schaefer@de.ibm.com>
First post2017-05-03 15:00 +0200
Last post2017-05-03 20:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] brd: fix uninitialized use of brd->dax_dev Gerald Schaefer <gerald.schaefer@de.ibm.com> - 2017-05-03 15:00 +0200
    Re: [PATCH] brd: fix uninitialized use of brd->dax_dev Dan Williams <dan.j.williams@intel.com> - 2017-05-03 20:50 +0200

#1634966 — [PATCH] brd: fix uninitialized use of brd->dax_dev

FromGerald Schaefer <gerald.schaefer@de.ibm.com>
Date2017-05-03 15:00 +0200
Subject[PATCH] brd: fix uninitialized use of brd->dax_dev
Message-ID<tD22S-5vI-7@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1635206

FromDan Williams <dan.j.williams@intel.com>
Date2017-05-03 20:50 +0200
Message-ID<tD7vA-Hg-13@gated-at.bofh.it>
In reply to#1634966
On Wed, May 3, 2017 at 5:56 AM, Gerald Schaefer
<gerald.schaefer@de.ibm.com> wrote:
> 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>

Thanks Gerald, I added this to the dax_device conversion for 4.12.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web