All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/bnxt_re: Check return value from get_link_ksettings
@ 2017-06-05  9:14 Yuval Shaia
       [not found] ` <20170605091429.16232-1-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Yuval Shaia @ 2017-06-05  9:14 UTC (permalink / raw)
  To: selvin.xavier-dY08KVG/lbpWk0Htik3J/w,
	devesh.sharma-dY08KVG/lbpWk0Htik3J/w,
	somnath.kotur-dY08KVG/lbpWk0Htik3J/w,
	sriharsha.basavapatna-dY08KVG/lbpWk0Htik3J/w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Yuval Shaia

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 <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
 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:
-- 
2.9.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-06-06 11:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05  9:14 [PATCH] IB/bnxt_re: Check return value from get_link_ksettings Yuval Shaia
     [not found] ` <20170605091429.16232-1-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-06-05 10:42   ` Moni Shoua
     [not found]     ` <CAG9sBKODJaecc2m-GTqU8H=jttPAr+iCcZK0wknEfXerz6TL+A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-05 12:42       ` Yuval Shaia
2017-06-05 13:38         ` Leon Romanovsky
     [not found]           ` <20170605133831.GO6868-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-06-05 14:30             ` Yuval Shaia
2017-06-05 15:04               ` Moni Shoua
     [not found]                 ` <CAG9sBKPkW9kedMUTOYPESUm8gJkYk4vRSuC3amOCNa+fHEnw+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-06 11:30                   ` Yuval Shaia
2017-06-05 12:52   ` Leon Romanovsky
     [not found]     ` <20170605125227.GM6868-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-06-05 12:54       ` Leon Romanovsky
     [not found]         ` <20170605125415.GN6868-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-06-05 13:33           ` Yuval Shaia
2017-06-05 13:11   ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.