diff mbox

IB/core: Fix uninitialized variable use in check_qp_port_pkey_settings

Message ID 1498833335-937-1-git-send-email-danielj@mellanox.com (mailing list archive)
State Accepted
Headers show

Commit Message

Daniel Jurgens June 30, 2017, 2:35 p.m. UTC
From: Daniel Jurgens <danielj@mellanox.com>

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>
---
 drivers/infiniband/core/security.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

Comments

Paul Moore July 1, 2017, 1:40 p.m. UTC | #1
On Fri, Jun 30, 2017 at 10:35 AM, Dan Jurgens <danielj@mellanox.com> wrote:
> From: Daniel Jurgens <danielj@mellanox.com>
>
> 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>
> ---
>  drivers/infiniband/core/security.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)

Since the original patch went in via the SELinux tree, would the
IB/RDMA folks prefer this to go in via the SELinux tree as well?
Paul Moore July 3, 2017, 11:02 p.m. UTC | #2
On Sat, Jul 1, 2017 at 9:40 AM, Paul Moore <paul@paul-moore.com> wrote:
> On Fri, Jun 30, 2017 at 10:35 AM, Dan Jurgens <danielj@mellanox.com> wrote:
>> From: Daniel Jurgens <danielj@mellanox.com>
>>
>> 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>
>> ---
>>  drivers/infiniband/core/security.c | 20 ++++++++++++--------
>>  1 file changed, 12 insertions(+), 8 deletions(-)
>
> Since the original patch went in via the SELinux tree, would the
> IB/RDMA folks prefer this to go in via the SELinux tree as well?

I went ahead and merged this into the selinux/stable-4.13 tree and I'm
doing a sanity build now, assuming all goes well I'll send this up for
v4.13.
diff mbox

Patch

diff --git a/drivers/infiniband/core/security.c b/drivers/infiniband/core/security.c
index 3e8c389..70ad19c 100644
--- a/drivers/infiniband/core/security.c
+++ b/drivers/infiniband/core/security.c
@@ -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,