]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
IB/core: Fix uninitialized variable use in check_qp_port_pkey_settings
authorDaniel Jurgens <danielj@mellanox.com>
Fri, 30 Jun 2017 14:35:35 +0000 (17:35 +0300)
committerJames Morris <james.l.morris@oracle.com>
Thu, 6 Jul 2017 23:49:26 +0000 (09:49 +1000)
Check the return value from get_pkey_and_subnet_prefix to prevent using
uninitialized variables.

Fixes: d291f1a65232 ("IB/core: Enforce PKey security on QPs")
Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
drivers/infiniband/core/security.c

index 3e8c389539127b7c52daaa4d0ab361498502ed04..70ad19c4c73e77da961ffccd9958887dcead8027 100644 (file)
@@ -120,21 +120,25 @@ static int check_qp_port_pkey_settings(struct ib_ports_pkeys *pps,
                return 0;
 
        if (pps->main.state != IB_PORT_PKEY_NOT_VALID) {
-               get_pkey_and_subnet_prefix(&pps->main,
-                                          &pkey,
-                                          &subnet_prefix);
+               ret = get_pkey_and_subnet_prefix(&pps->main,
+                                                &pkey,
+                                                &subnet_prefix);
+               if (ret)
+                       return ret;
 
                ret = enforce_qp_pkey_security(pkey,
                                               subnet_prefix,
                                               sec);
+               if (ret)
+                       return ret;
        }
-       if (ret)
-               return ret;
 
        if (pps->alt.state != IB_PORT_PKEY_NOT_VALID) {
-               get_pkey_and_subnet_prefix(&pps->alt,
-                                          &pkey,
-                                          &subnet_prefix);
+               ret = get_pkey_and_subnet_prefix(&pps->alt,
+                                                &pkey,
+                                                &subnet_prefix);
+               if (ret)
+                       return ret;
 
                ret = enforce_qp_pkey_security(pkey,
                                               subnet_prefix,