aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Schaefer <gerald.schaefer@de.ibm.com>2017-05-03 08:56:02 -0400
committerDan Williams <dan.j.williams@intel.com>2017-05-03 14:30:03 -0400
commit1ef97fe4f8abd3317d5c3c860f990e02c2633959 (patch)
treefd6400daa598e5f60d5c3502fa93c8fb5c2fd7e5
parent67fd38973513c341c84654ae2f819089b840a39b (diff)
brd: fix uninitialized use of brd->dax_dev
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> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/block/brd.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index bfa4ed2c75ef..ec00c01b8dc3 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -453,9 +453,7 @@ static struct brd_device *brd_alloc(int i)
453{ 453{
454 struct brd_device *brd; 454 struct brd_device *brd;
455 struct gendisk *disk; 455 struct gendisk *disk;
456#ifdef CONFIG_BLK_DEV_RAM_DAX 456
457 struct dax_device *dax_dev;
458#endif
459 brd = kzalloc(sizeof(*brd), GFP_KERNEL); 457 brd = kzalloc(sizeof(*brd), GFP_KERNEL);
460 if (!brd) 458 if (!brd)
461 goto out; 459 goto out;
@@ -497,8 +495,8 @@ static struct brd_device *brd_alloc(int i)
497 495
498#ifdef CONFIG_BLK_DEV_RAM_DAX 496#ifdef CONFIG_BLK_DEV_RAM_DAX
499 queue_flag_set_unlocked(QUEUE_FLAG_DAX, brd->brd_queue); 497 queue_flag_set_unlocked(QUEUE_FLAG_DAX, brd->brd_queue);
500 dax_dev = alloc_dax(brd, disk->disk_name, &brd_dax_ops); 498 brd->dax_dev = alloc_dax(brd, disk->disk_name, &brd_dax_ops);
501 if (!dax_dev) 499 if (!brd->dax_dev)
502 goto out_free_inode; 500 goto out_free_inode;
503#endif 501#endif
504 502
@@ -507,8 +505,8 @@ static struct brd_device *brd_alloc(int i)
507 505
508#ifdef CONFIG_BLK_DEV_RAM_DAX 506#ifdef CONFIG_BLK_DEV_RAM_DAX
509out_free_inode: 507out_free_inode:
510 kill_dax(dax_dev); 508 kill_dax(brd->dax_dev);
511 put_dax(dax_dev); 509 put_dax(brd->dax_dev);
512#endif 510#endif
513out_free_queue: 511out_free_queue:
514 blk_cleanup_queue(brd->brd_queue); 512 blk_cleanup_queue(brd->brd_queue);