diff mbox

[1/2] IB/rxe: Check return value from get_settings

Message ID 20170605081241.17920-2-yuval.shaia@oracle.com (mailing list archive)
State Superseded
Headers show

Commit Message

Yuval Shaia June 5, 2017, 8:12 a.m. UTC
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 <yuval.shaia@oracle.com>
---
 drivers/infiniband/sw/rxe/rxe_verbs.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox

Patch

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;