Skip to content

Commit 4eaf093

Browse files
mbrozaxboe
authored andcommitted
block: Fix regression in sed-opal for a saved key.
The commit 3bfeb61 introduced the use of keyring for sed-opal. Unfortunately, there is also a possibility to save the Opal key used in opal_lock_unlock(). This patch switches the order of operation, so the cached key is used instead of failure for opal_get_key. The problem was found by the cryptsetup Opal test recently added to the cryptsetup tree. Fixes: 3bfeb61 ("block: sed-opal: keyring support for SED keys") Tested-by: Ondrej Kozina <[email protected]> Signed-off-by: Milan Broz <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 1364a3c commit 4eaf093

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

block/sed-opal.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,12 +2888,11 @@ static int opal_lock_unlock(struct opal_dev *dev,
28882888
if (lk_unlk->session.who > OPAL_USER9)
28892889
return -EINVAL;
28902890

2891-
ret = opal_get_key(dev, &lk_unlk->session.opal_key);
2892-
if (ret)
2893-
return ret;
28942891
mutex_lock(&dev->dev_lock);
28952892
opal_lock_check_for_saved_key(dev, lk_unlk);
2896-
ret = __opal_lock_unlock(dev, lk_unlk);
2893+
ret = opal_get_key(dev, &lk_unlk->session.opal_key);
2894+
if (!ret)
2895+
ret = __opal_lock_unlock(dev, lk_unlk);
28972896
mutex_unlock(&dev->dev_lock);
28982897

28992898
return ret;

0 commit comments

Comments
 (0)