diff --git a/block/sed-opal.c b/block/sed-opal.c
index 14fe0fef811cfc2fb5e84047a592fa7a309addb4..598fd3e7fcc8e2a1d0a752e1265f1e4c2a09eae5 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -314,7 +314,7 @@ static int read_sed_opal_key(const char *key_name, u_char *buffer, int buflen)
 			      &key_type_user, key_name, true);
 
 	if (IS_ERR(kref))
-		ret = PTR_ERR(kref);
+		return PTR_ERR(kref);
 
 	key = key_ref_to_ptr(kref);
 	down_read(&key->sem);