diff mbox

IB/rxe: Check return value from get_settings

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

Commit Message

Yuval Shaia June 4, 2017, 5:06 p.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(-)

Comments

Leon Romanovsky June 4, 2017, 5:26 p.m. UTC | #1
On Sun, Jun 04, 2017 at 08:06:19PM +0300, Yuval Shaia wrote:
> 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(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Yuval Shaia June 5, 2017, 7:59 a.m. UTC | #2
On Sun, Jun 04, 2017 at 08:26:30PM +0300, Leon Romanovsky wrote:
> On Sun, Jun 04, 2017 at 08:06:19PM +0300, Yuval Shaia wrote:
> > 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(-)
> >
> 
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

Thanks Leon for your review.
I'm about to post another version for this patch and will appreciate your
review.
Looks like call to get_link_ksettings should be protected by rtnl lock, it
is undocumented but for example __ethtool_get_link_ksettings prints an ugly
dump_stack when this happen.
I will do the same as what is done in function __to_ib_speed_width

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
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;