mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-13 11:07:46 +10:00
block: Fix regression in sed-opal for a saved key.
The commit3bfeb61256
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:3bfeb61256
("block: sed-opal: keyring support for SED keys") Tested-by: Ondrej Kozina <okozina@redhat.com> Signed-off-by: Milan Broz <gmazyland@gmail.com> Link: https://lore.kernel.org/r/20231003100209.380037-1-gmazyland@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
1364a3c391
commit
4eaf0932c6
@ -2888,11 +2888,10 @@ static int opal_lock_unlock(struct opal_dev *dev,
|
|||||||
if (lk_unlk->session.who > OPAL_USER9)
|
if (lk_unlk->session.who > OPAL_USER9)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ret = opal_get_key(dev, &lk_unlk->session.opal_key);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
mutex_lock(&dev->dev_lock);
|
mutex_lock(&dev->dev_lock);
|
||||||
opal_lock_check_for_saved_key(dev, lk_unlk);
|
opal_lock_check_for_saved_key(dev, lk_unlk);
|
||||||
|
ret = opal_get_key(dev, &lk_unlk->session.opal_key);
|
||||||
|
if (!ret)
|
||||||
ret = __opal_lock_unlock(dev, lk_unlk);
|
ret = __opal_lock_unlock(dev, lk_unlk);
|
||||||
mutex_unlock(&dev->dev_lock);
|
mutex_unlock(&dev->dev_lock);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user