diff options
author | Scott Bauer <scott.bauer@intel.com> | 2017-02-22 10:15:06 -0700 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-02-23 11:55:41 -0700 |
commit | 7d6d15789d69856f1c5405e106a773c87277eb8c (patch) | |
tree | 7ae43ae226e85c4db783756a3c07f14ed1dbd0cf /block | |
parent | 124298bd03acebd9c9da29a794718aca31bec1f7 (diff) | |
download | linux-7d6d15789d69856f1c5405e106a773c87277eb8c.tar.gz linux-7d6d15789d69856f1c5405e106a773c87277eb8c.tar.bz2 linux-7d6d15789d69856f1c5405e106a773c87277eb8c.zip |
block/sed-opal: Introduce free_opal_dev to free the structure and clean up state
Before we free the opal structure we need to clean up any saved
locking ranges that the user had told us to unlock from a suspend.
Signed-off-by: Scott Bauer <scott.bauer@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/sed-opal.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/block/sed-opal.c b/block/sed-opal.c index 893557554cc5..020bf3e28e38 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -1987,6 +1987,28 @@ static int check_opal_support(struct opal_dev *dev) return ret; } +static void clean_opal_dev(struct opal_dev *dev) +{ + + struct opal_suspend_data *suspend, *next; + + mutex_lock(&dev->dev_lock); + list_for_each_entry_safe(suspend, next, &dev->unlk_lst, node) { + list_del(&suspend->node); + kfree(suspend); + } + mutex_unlock(&dev->dev_lock); +} + +void free_opal_dev(struct opal_dev *dev) +{ + if (!dev) + return; + clean_opal_dev(dev); + kfree(dev); +} +EXPORT_SYMBOL(free_opal_dev); + struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv) { struct opal_dev *dev; @@ -2141,6 +2163,14 @@ static int opal_reverttper(struct opal_dev *dev, struct opal_key *opal) setup_opal_dev(dev, revert_steps); ret = next(dev); mutex_unlock(&dev->dev_lock); + + /* + * If we successfully reverted lets clean + * any saved locking ranges. + */ + if (!ret) + clean_opal_dev(dev); + return ret; } |