From patchwork Mon Jun 5 09:14:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 9765971 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 D1F13602BF for ; Mon, 5 Jun 2017 09:14:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D060B26538 for ; Mon, 5 Jun 2017 09:14:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4DB326E69; Mon, 5 Jun 2017 09:14:49 +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 4B63326538 for ; Mon, 5 Jun 2017 09:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751287AbdFEJOs (ORCPT ); Mon, 5 Jun 2017 05:14:48 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:35675 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751280AbdFEJOr (ORCPT ); Mon, 5 Jun 2017 05:14:47 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v559Ebsq028504 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Jun 2017 09:14:38 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 v559Eb99000986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Jun 2017 09:14:37 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v559EakE031842; Mon, 5 Jun 2017 09:14:36 GMT Received: from localhost.localdomain (/77.138.186.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Jun 2017 02:14:36 -0700 From: Yuval Shaia To: selvin.xavier@broadcom.com, devesh.sharma@broadcom.com, somnath.kotur@broadcom.com, sriharsha.basavapatna@broadcom.com, dledford@redhat.com, sean.hefty@intel.com, hal.rosenstock@gmail.com, linux-rdma@vger.kernel.org Cc: Yuval Shaia Subject: [PATCH] IB/bnxt_re: Check return value from get_link_ksettings Date: Mon, 5 Jun 2017 12:14:29 +0300 Message-Id: <20170605091429.16232-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 function get_link_ksettings might return bad status indicating a failure to retrieve interface atttibutes. Check return value to cover this case. While there, change the zero-initialization to "compiler-helper" instead of an expensive call to memcpy. Signed-off-by: Yuval Shaia Reviewed-by: Leon Romanovsky --- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index 7ba9e69..10c7189 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -183,17 +183,19 @@ int bnxt_re_modify_device(struct ib_device *ibdev, static void __to_ib_speed_width(struct net_device *netdev, u8 *speed, u8 *width) { - struct ethtool_link_ksettings lksettings; - u32 espeed; + u32 espeed = SPEED_UNKNOWN; if (netdev->ethtool_ops && netdev->ethtool_ops->get_link_ksettings) { - memset(&lksettings, 0, sizeof(lksettings)); + struct ethtool_link_ksettings lksettings = {0}; + int rc; + rtnl_lock(); - netdev->ethtool_ops->get_link_ksettings(netdev, &lksettings); + rc = netdev->ethtool_ops->get_link_ksettings(netdev, + &lksettings); rtnl_unlock(); - espeed = lksettings.base.speed; - } else { - espeed = SPEED_UNKNOWN; + + if (!rc) + espeed = lksettings.base.speed; } switch (espeed) { case SPEED_1000: