dm cache: fix use after freeing migrations
authorJoe Thornber <ejt@redhat.com>
Tue, 1 Sep 2015 10:38:19 +0000 (11:38 +0100)
committerMike Snitzer <snitzer@redhat.com>
Tue, 1 Sep 2015 12:56:14 +0000 (08:56 -0400)
commitcc7da0ba9c96699592d0a69d7d146ac6adcc18e7
tree84a021e91e6bb4a9e395315fcf4a80bfc3f3fd51
parentdc9cee5db50afaf38506bc12eb479fb8ea536dba
dm cache: fix use after freeing migrations

Both free_io_migration() and issue_discard() dereference a migration
that was just freed.  Fix those by saving off the migrations's cache
object before freeing the migration.  Also cleanup needless mg->cache
dereferences now that the cache object is available directly.

Fixes: e44b6a5a3c ("dm cache: move wake_waker() from free_migrations() to where it is needed")
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-cache-target.c