]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
keys: Remove redundant less-than-zero checks
authorThorsten Blum <thorsten.blum@linux.dev>
Sat, 11 Oct 2025 14:48:24 +0000 (16:48 +0200)
committerJarkko Sakkinen <jarkko@kernel.org>
Thu, 27 Nov 2025 21:50:20 +0000 (23:50 +0200)
The local variables 'size_t datalen' are unsigned and cannot be less
than zero. Remove the redundant conditions.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
security/keys/big_key.c
security/keys/encrypted-keys/encrypted.c
security/keys/trusted-keys/trusted_core.c
security/keys/user_defined.c

index c3367622c683be8678e9224f2fc041741f3c70e8..d46862ab90d6d9593ce580715e1669ef6ca69d59 100644 (file)
@@ -66,7 +66,7 @@ int big_key_preparse(struct key_preparsed_payload *prep)
 
        BUILD_BUG_ON(sizeof(*payload) != sizeof(prep->payload.data));
 
-       if (datalen <= 0 || datalen > 1024 * 1024 || !prep->data)
+       if (datalen == 0 || datalen > 1024 * 1024 || !prep->data)
                return -EINVAL;
 
        /* Set an arbitrary quota */
index 513c09e2b01cf22dc1f55bcd7b0863107407d6aa..596e7a30bd3c0ce68fd6f39391db490590882764 100644 (file)
@@ -795,7 +795,7 @@ static int encrypted_instantiate(struct key *key,
        size_t datalen = prep->datalen;
        int ret;
 
-       if (datalen <= 0 || datalen > 32767 || !prep->data)
+       if (datalen == 0 || datalen > 32767 || !prep->data)
                return -EINVAL;
 
        datablob = kmalloc(datalen + 1, GFP_KERNEL);
@@ -856,7 +856,7 @@ static int encrypted_update(struct key *key, struct key_preparsed_payload *prep)
 
        if (key_is_negative(key))
                return -ENOKEY;
-       if (datalen <= 0 || datalen > 32767 || !prep->data)
+       if (datalen == 0 || datalen > 32767 || !prep->data)
                return -EINVAL;
 
        buf = kmalloc(datalen + 1, GFP_KERNEL);
index e2d9644efde157bf26fbcb328888c54d86eb6466..b1680ee53f86192711a9c95be7e2bfb9ade1a6f0 100644 (file)
@@ -157,7 +157,7 @@ static int trusted_instantiate(struct key *key,
        int key_cmd;
        size_t key_len;
 
-       if (datalen <= 0 || datalen > 32767 || !prep->data)
+       if (datalen == 0 || datalen > 32767 || !prep->data)
                return -EINVAL;
 
        orig_datablob = datablob = kmalloc(datalen + 1, GFP_KERNEL);
@@ -240,7 +240,7 @@ static int trusted_update(struct key *key, struct key_preparsed_payload *prep)
        p = key->payload.data[0];
        if (!p->migratable)
                return -EPERM;
-       if (datalen <= 0 || datalen > 32767 || !prep->data)
+       if (datalen == 0 || datalen > 32767 || !prep->data)
                return -EINVAL;
 
        orig_datablob = datablob = kmalloc(datalen + 1, GFP_KERNEL);
index 749e2a4dcb13ee6799d3a06daccfa1ab6e47ae11..686d56e4cc85096dcdb4947de6e602d5e906cc7b 100644 (file)
@@ -61,7 +61,7 @@ int user_preparse(struct key_preparsed_payload *prep)
        struct user_key_payload *upayload;
        size_t datalen = prep->datalen;
 
-       if (datalen <= 0 || datalen > 32767 || !prep->data)
+       if (datalen == 0 || datalen > 32767 || !prep->data)
                return -EINVAL;
 
        upayload = kmalloc(sizeof(*upayload) + datalen, GFP_KERNEL);