All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
	dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org
Subject: [PATCH 1/2] IB/rxe: Check return value from get_settings
Date: Mon,  5 Jun 2017 11:12:40 +0300	[thread overview]
Message-ID: <20170605081241.17920-2-yuval.shaia@oracle.com> (raw)
In-Reply-To: <20170605081241.17920-1-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
 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;
-- 
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

  parent reply	other threads:[~2017-06-05  8:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-05  8:12 Two fixes for rxe_query_port Yuval Shaia
     [not found] ` <20170605081241.17920-1-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-06-05  8:12   ` Yuval Shaia [this message]
2017-06-05  8:12   ` [PATCH 2/2] IB/rxe: Protect call to get_link_ksettings with rtnl lock Yuval Shaia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170605081241.17920-2-yuval.shaia@oracle.com \
    --to=yuval.shaia-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.