diff mbox

[v2,2/2] usnic: do not ignore return value of __ethtool_get_link_ksettings

Message ID 20170720182340.28864-2-gvaradar@cisco.com (mailing list archive)
State Superseded
Headers show

Commit Message

Govindarajulu Varadarajan (gvaradar) July 20, 2017, 6:23 p.m. UTC
Do not ignore the return value of the caller.

Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
---
v2: Do not initialize err as it is over written later

 drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Yuval Shaia July 20, 2017, 7:39 p.m. UTC | #1
On Thu, Jul 20, 2017 at 11:23:40AM -0700, Govindarajulu Varadarajan wrote:
> Do not ignore the return value of the caller.
> 
> Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
> ---
> v2: Do not initialize err as it is over written later
> 
>  drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
> index 03002bac93e7..f7be74740b3f 100644
> --- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
> +++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
> @@ -327,13 +327,16 @@ int usnic_ib_query_port(struct ib_device *ibdev, u8 port,
>  {
>  	struct usnic_ib_dev *us_ibdev = to_usdev(ibdev);
>  	struct ethtool_link_ksettings cmd;
> +	int err;
>  
>  	usnic_dbg("\n");
>  
>  	mutex_lock(&us_ibdev->usdev_lock);
>  	rtnl_lock();
> -	__ethtool_get_link_ksettings(us_ibdev->netdev, &cmd);
> +	err = __ethtool_get_link_ksettings(us_ibdev->netdev, &cmd);

Same here, already handled in http://marc.info/?l=linux-rdma&m=150023353924211&w=2

>  	rtnl_unlock();
> +	if (err)
> +		goto out;
>  	/* props being zeroed by the caller, avoid zeroing it here */
>  
>  	props->lid = 0;
> @@ -364,9 +367,10 @@ int usnic_ib_query_port(struct ib_device *ibdev, u8 port,
>  	/* Userspace will adjust for hdrs */
>  	props->max_msg_sz = us_ibdev->ufdev->mtu;
>  	props->max_vl_num = 1;
> +out:
>  	mutex_unlock(&us_ibdev->usdev_lock);
>  
> -	return 0;
> +	return err;
>  }
>  
>  int usnic_ib_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
> -- 
> 2.13.3
> 
> --
> 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
--
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/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
index 03002bac93e7..f7be74740b3f 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
@@ -327,13 +327,16 @@  int usnic_ib_query_port(struct ib_device *ibdev, u8 port,
 {
 	struct usnic_ib_dev *us_ibdev = to_usdev(ibdev);
 	struct ethtool_link_ksettings cmd;
+	int err;
 
 	usnic_dbg("\n");
 
 	mutex_lock(&us_ibdev->usdev_lock);
 	rtnl_lock();
-	__ethtool_get_link_ksettings(us_ibdev->netdev, &cmd);
+	err = __ethtool_get_link_ksettings(us_ibdev->netdev, &cmd);
 	rtnl_unlock();
+	if (err)
+		goto out;
 	/* props being zeroed by the caller, avoid zeroing it here */
 
 	props->lid = 0;
@@ -364,9 +367,10 @@  int usnic_ib_query_port(struct ib_device *ibdev, u8 port,
 	/* Userspace will adjust for hdrs */
 	props->max_msg_sz = us_ibdev->ufdev->mtu;
 	props->max_vl_num = 1;
+out:
 	mutex_unlock(&us_ibdev->usdev_lock);
 
-	return 0;
+	return err;
 }
 
 int usnic_ib_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,