From patchwork Mon Jun 5 08:12:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 9765711 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 49246602B6 for ; Mon, 5 Jun 2017 08:13:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39EFB274D1 for ; Mon, 5 Jun 2017 08:13:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E2C927E71; Mon, 5 Jun 2017 08:13:02 +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 A32B9274D1 for ; Mon, 5 Jun 2017 08:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751511AbdFEINA (ORCPT ); Mon, 5 Jun 2017 04:13:00 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:17170 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751356AbdFEINA (ORCPT ); Mon, 5 Jun 2017 04:13:00 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v558CpYQ025177 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Jun 2017 08:12:51 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v558CoX0019456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Jun 2017 08:12:51 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v558CoLL006308; Mon, 5 Jun 2017 08:12:50 GMT Received: from localhost.localdomain (/77.138.186.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Jun 2017 01:12:50 -0700 From: Yuval Shaia To: monis@mellanox.com, dledford@redhat.com, sean.hefty@intel.com, hal.rosenstock@gmail.com, linux-rdma@vger.kernel.org, leon@kernel.org, yuval.shaia@oracle.com Subject: [PATCH 1/2] IB/rxe: Check return value from get_settings Date: Mon, 5 Jun 2017 11:12:40 +0300 Message-Id: <20170605081241.17920-2-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170605081241.17920-1-yuval.shaia@oracle.com> References: <20170605081241.17920-1-yuval.shaia@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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 The functions get_link_ksettings and get_settings might return bad status indicating a failure to retrieve interface atttibutes. Check return value to cover this case. Signed-off-by: Yuval Shaia --- drivers/infiniband/sw/rxe/rxe_verbs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 83d709e..ffd3888 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -81,6 +81,7 @@ static int rxe_query_port(struct ib_device *dev, struct rxe_dev *rxe = to_rdev(dev); struct rxe_port *port; u32 speed; + int rc = -EINVAL; if (unlikely(port_num != 1)) { pr_warn("invalid port_number %d\n", port_num); @@ -96,14 +97,15 @@ static int rxe_query_port(struct ib_device *dev, if (rxe->ndev->ethtool_ops->get_link_ksettings) { struct ethtool_link_ksettings ks; - rxe->ndev->ethtool_ops->get_link_ksettings(rxe->ndev, &ks); + rc = rxe->ndev->ethtool_ops->get_link_ksettings(rxe->ndev, &ks); speed = ks.base.speed; } else if (rxe->ndev->ethtool_ops->get_settings) { struct ethtool_cmd cmd; - rxe->ndev->ethtool_ops->get_settings(rxe->ndev, &cmd); + rc = rxe->ndev->ethtool_ops->get_settings(rxe->ndev, &cmd); speed = cmd.speed; - } else { + } + if (rc) { pr_warn("%s speed is unknown, defaulting to 1000\n", rxe->ndev->name); speed = 1000;