From patchwork Sun Jun 4 17:06:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 9765053 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 E54196032D for ; Sun, 4 Jun 2017 17:06:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF74828047 for ; Sun, 4 Jun 2017 17:06:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C439C280DE; Sun, 4 Jun 2017 17:06:42 +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 BB74528047 for ; Sun, 4 Jun 2017 17:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750949AbdFDRGk (ORCPT ); Sun, 4 Jun 2017 13:06:40 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:21836 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750931AbdFDRGk (ORCPT ); Sun, 4 Jun 2017 13:06:40 -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 v54H6Ss0012673 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 4 Jun 2017 17:06:28 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v54H6SvF007891 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 4 Jun 2017 17:06:28 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v54H6PA9028605; Sun, 4 Jun 2017 17:06:27 GMT Received: from localhost.localdomain (/77.138.186.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 04 Jun 2017 10:06:25 -0700 From: Yuval Shaia To: monis@mellanox.com, dledford@redhat.com, sean.hefty@intel.com, hal.rosenstock@gmail.com, linux-rdma@vger.kernel.org Cc: Yuval Shaia Subject: [PATCH] IB/rxe: Check return value from get_settings Date: Sun, 4 Jun 2017 20:06:19 +0300 Message-Id: <20170604170619.3697-1-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.9.4 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 Reviewed-by: Leon Romanovsky --- 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;