When blk_ksm_find_keyslot() returns NULL to slot, no error return code of blk_ksm_evict_key() is assigned. To fix this bug, err is assigned with -ENOENT in this case. Fixes: 1b2628397058 ("block: Keyslot Manager for Inline Encryption") Reported-by: TOTE Robot <oslab@xxxxxxxxxxxxxxx> Signed-off-by: Jia-Ju Bai <baijiaju1990@xxxxxxxxx> --- block/keyslot-manager.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/keyslot-manager.c b/block/keyslot-manager.c index 2c4a55bea6ca..4dd5da0645bc 100644 --- a/block/keyslot-manager.c +++ b/block/keyslot-manager.c @@ -375,8 +375,10 @@ int blk_ksm_evict_key(struct blk_keyslot_manager *ksm, blk_ksm_hw_enter(ksm); slot = blk_ksm_find_keyslot(ksm, key); - if (!slot) + if (!slot) { + err = -ENOENT; goto out_unlock; + } if (WARN_ON_ONCE(atomic_read(&slot->slot_refs) != 0)) { err = -EBUSY; -- 2.17.1