Fix bad pointer du->sysfs_root
authorTomohiro Kusumi <tkusumi@tuxera.com>
Mon, 23 Jan 2017 15:13:10 +0000 (00:13 +0900)
committerJens Axboe <axboe@fb.com>
Mon, 23 Jan 2017 15:26:12 +0000 (08:26 -0700)
commit2a20eebccf88b3be2c56d4b5cd6cb4466b289e4f
tree9a6a87c5716640c18b02089743bae4f71c2980cc
parentecf74245706c8a1a01cd461b2b213cb1e90573e1
Fix bad pointer du->sysfs_root

There are two call paths for disk_util_add() (usually the second one)
which assigns ->sysfs_root for a newly allocated disk_util*, but both
temppath/foo are local char[] within their stack, so strdup/free it.

-> find_add_disk_slaves(...)
  -> __init_per_file_disk_util(..., temppath)
    -> disk_util_add(..., path)
      -> du->sysfs_root = path; /* == &temppath[0] */

-> init_per_file_disk_util(...)
  -> __init_per_file_disk_util(..., foo)
    -> disk_util_add(..., path)
      -> du->sysfs_root = path; /* == &foo[0] */

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
diskutil.c