CHROMIUM: dm-bht: fix invalid mempool_free call
authorWill Drewry <wad@chromium.org>
Thu, 28 Oct 2010 21:25:21 +0000 (16:25 -0500)
committerOlof Johansson <olof@lixom.net>
Fri, 1 Jun 2012 06:59:32 +0000 (23:59 -0700)
dm-bht allocates pages from a page pool, then uses the virtual address most of
the time.  This flip-flopped a few times and the result is that the
mempool_free call is using the virtual address instead of the page pointer that
was yielded from the page pool.

This change fixes that oversight simply with  virt_to_page() call.  In the
future, this should be cleaned up to just keep the page around and use
page_address() calls when the virtual address is needed.

The reason this fix is preferable for now is that it doesn't impact any of the
active use code - just device removal which only occurs in the recovery
scenario.

TEST=recovery dmsetup remove calls no longer panic()
BUG=chromium-os:7451

Change-Id: I7d7493b55f6ae8668d5e5e8dc3a347be84878afc
Signed-off-by: Will Drewry <wad@chromium.org>
Review URL: http://codereview.chromium.org/4163004

drivers/md/dm-bht.c

index d8d8fe1..cf4f80c 100644 (file)
@@ -1172,7 +1172,8 @@ int dm_bht_destroy(struct dm_bht *bht)
                                continue;
                        default:
                                BUG_ON(!entry->nodes);
-                               mempool_free(entry->nodes, bht->entry_pool);
+                               mempool_free(virt_to_page(entry->nodes),
+                                            bht->entry_pool);
                                break;
                        }
                }