]> www.infradead.org Git - nvme.git/commitdiff
block: sed-opal: avoid possible wrong address reference in read_sed_opal_key()
authorSu Hui <suhui@nfschina.com>
Tue, 11 Jun 2024 07:37:00 +0000 (15:37 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 12 Jun 2024 16:53:20 +0000 (10:53 -0600)
Clang static checker (scan-build) warning:
block/sed-opal.c:line 317, column 3
Value stored to 'ret' is never read.

Fix this problem by returning the error code when keyring_search() failed.
Otherwise, 'key' will have a wrong value when 'kerf' stores the error code.

Fixes: 3bfeb6125664 ("block: sed-opal: keyring support for SED keys")
Signed-off-by: Su Hui <suhui@nfschina.com>
Link: https://lore.kernel.org/r/20240611073659.429582-1-suhui@nfschina.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/sed-opal.c

index 14fe0fef811cfc2fb5e84047a592fa7a309addb4..598fd3e7fcc8e2a1d0a752e1265f1e4c2a09eae5 100644 (file)
@@ -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);