Skip to content

Commit

Permalink
brd: fix uninitialized use of brd->dax_dev
Browse files Browse the repository at this point in the history
commit 1647b9b "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 <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
  • Loading branch information
gerald-schaefer authored and djbw committed May 3, 2017
1 parent 67fd389 commit 1ef97fe
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/block/brd.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,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;
Expand Down Expand Up @@ -497,8 +495,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

Expand All @@ -507,8 +505,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);
Expand Down

0 comments on commit 1ef97fe

Please sign in to comment.