From patchwork Fri Jun 30 14:35:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Jurgens X-Patchwork-Id: 9819765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20D5B60224 for ; Fri, 30 Jun 2017 14:36:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E8602867B for ; Fri, 30 Jun 2017 14:36:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 027CD28694; Fri, 30 Jun 2017 14:36:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E42E2867B for ; Fri, 30 Jun 2017 14:36:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752423AbdF3OgO (ORCPT ); Fri, 30 Jun 2017 10:36:14 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:57106 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752421AbdF3OgM (ORCPT ); Fri, 30 Jun 2017 10:36:12 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from danielj@mellanox.com) with ESMTPS (AES256-SHA encrypted); 30 Jun 2017 17:35:44 +0300 Received: from x-vnc01.mtx.labs.mlnx (x-vnc01.mtx.labs.mlnx [10.12.150.16]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v5UEZgBF031372; Fri, 30 Jun 2017 17:35:42 +0300 From: Dan Jurgens To: paul@paul-moore.com, dan.carpenter@oracle.com, dledford@redhat.com Cc: selinux@tycho.nsa.gov, linux-rdma@vger.kernel.org, yevgenyp@mellanox.com, Daniel Jurgens Subject: [PATCH] IB/core: Fix uninitialized variable use in check_qp_port_pkey_settings Date: Fri, 30 Jun 2017 17:35:35 +0300 Message-Id: <1498833335-937-1-git-send-email-danielj@mellanox.com> X-Mailer: git-send-email 1.7.1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Jurgens 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 Reported-by: Dan Carpenter --- drivers/infiniband/core/security.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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,