]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
s390: zcrypt: initialize variables before_use
authorArnd Bergmann <arnd@arndb.de>
Mon, 8 Apr 2019 21:26:18 +0000 (23:26 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Thu, 11 Apr 2019 11:37:30 +0000 (13:37 +0200)
The 'func_code' variable gets printed in debug statements without
a prior initialization in multiple functions, as reported when building
with clang:

drivers/s390/crypto/zcrypt_api.c:659:6: warning: variable 'func_code' is used uninitialized whenever 'if' condition is true
      [-Wsometimes-uninitialized]
        if (mex->outputdatalength < mex->inputdatalength) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/s390/crypto/zcrypt_api.c:725:29: note: uninitialized use occurs here
        trace_s390_zcrypt_rep(mex, func_code, rc,
                                   ^~~~~~~~~
drivers/s390/crypto/zcrypt_api.c:659:2: note: remove the 'if' if its condition is always false
        if (mex->outputdatalength < mex->inputdatalength) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/s390/crypto/zcrypt_api.c:654:24: note: initialize the variable 'func_code' to silence this warning
        unsigned int func_code;
                              ^

Add initializations to all affected code paths to shut up the warning
and make the warning output consistent.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/crypto/zcrypt_api.c

index 689c2af7026a3adcf08e2e6eb019d9352e6de9d4..c31b2d31cd83203674dee10a706c34b204e93e12 100644 (file)
@@ -659,6 +659,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms,
        trace_s390_zcrypt_req(mex, TP_ICARSAMODEXPO);
 
        if (mex->outputdatalength < mex->inputdatalength) {
+               func_code = 0;
                rc = -EINVAL;
                goto out;
        }
@@ -742,6 +743,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms,
        trace_s390_zcrypt_req(crt, TP_ICARSACRT);
 
        if (crt->outputdatalength < crt->inputdatalength) {
+               func_code = 0;
                rc = -EINVAL;
                goto out;
        }
@@ -951,6 +953,7 @@ static long zcrypt_send_ep11_cprb(struct ap_perms *perms,
 
                targets = kcalloc(target_num, sizeof(*targets), GFP_KERNEL);
                if (!targets) {
+                       func_code = 0;
                        rc = -ENOMEM;
                        goto out;
                }
@@ -958,6 +961,7 @@ static long zcrypt_send_ep11_cprb(struct ap_perms *perms,
                uptr = (struct ep11_target_dev __force __user *) xcrb->targets;
                if (copy_from_user(targets, uptr,
                                   target_num * sizeof(*targets))) {
+                       func_code = 0;
                        rc = -EFAULT;
                        goto out_free;
                }