[net-next] ethtool: fix ->reply_size() error handling
diff mbox series

Message ID 20200108054125.feeckqg6xhab3wam@kili.mountain
State Accepted
Delegated to: David Miller
Headers show
Series
  • [net-next] ethtool: fix ->reply_size() error handling
Related show

Commit Message

Dan Carpenter Jan. 8, 2020, 5:41 a.m. UTC
The "ret < 0" comparison is never true because "ret" is still zero.

Fixes: 728480f12442 ("ethtool: default handlers for GET requests")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 net/ethtool/netlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Michal Kubecek Jan. 8, 2020, 9:08 a.m. UTC | #1
On Wed, Jan 08, 2020 at 08:41:25AM +0300, Dan Carpenter wrote:
> The "ret < 0" comparison is never true because "ret" is still zero.
> 
> Fixes: 728480f12442 ("ethtool: default handlers for GET requests")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  net/ethtool/netlink.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
> index 5d16436498ac..86b79f9bc08d 100644
> --- a/net/ethtool/netlink.c
> +++ b/net/ethtool/netlink.c
> @@ -319,9 +319,10 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
>  	rtnl_unlock();
>  	if (ret < 0)
>  		goto err_cleanup;
> -	reply_len = ops->reply_size(req_info, reply_data);
> +	ret = ops->reply_size(req_info, reply_data);
>  	if (ret < 0)
>  		goto err_cleanup;
> +	reply_len = ret;
>  	ret = -ENOMEM;
>  	rskb = ethnl_reply_init(reply_len, req_info->dev, ops->reply_cmd,
>  				ops->hdr_attr, info, &reply_payload);
> @@ -555,9 +556,10 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
>  	ret = ops->prepare_data(req_info, reply_data, NULL);
>  	if (ret < 0)
>  		goto err_cleanup;
> -	reply_len = ops->reply_size(req_info, reply_data);
> +	ret = ops->reply_size(req_info, reply_data);
>  	if (ret < 0)
>  		goto err_cleanup;
> +	reply_len = ret;
>  	ret = -ENOMEM;
>  	skb = genlmsg_new(reply_len, GFP_KERNEL);
>  	if (!skb)

Thank you.

Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
David Miller Jan. 9, 2020, 12:03 a.m. UTC | #2
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 8 Jan 2020 08:41:25 +0300

> The "ret < 0" comparison is never true because "ret" is still zero.
> 
> Fixes: 728480f12442 ("ethtool: default handlers for GET requests")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

Patch
diff mbox series

diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 5d16436498ac..86b79f9bc08d 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -319,9 +319,10 @@  static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
 	rtnl_unlock();
 	if (ret < 0)
 		goto err_cleanup;
-	reply_len = ops->reply_size(req_info, reply_data);
+	ret = ops->reply_size(req_info, reply_data);
 	if (ret < 0)
 		goto err_cleanup;
+	reply_len = ret;
 	ret = -ENOMEM;
 	rskb = ethnl_reply_init(reply_len, req_info->dev, ops->reply_cmd,
 				ops->hdr_attr, info, &reply_payload);
@@ -555,9 +556,10 @@  static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
 	ret = ops->prepare_data(req_info, reply_data, NULL);
 	if (ret < 0)
 		goto err_cleanup;
-	reply_len = ops->reply_size(req_info, reply_data);
+	ret = ops->reply_size(req_info, reply_data);
 	if (ret < 0)
 		goto err_cleanup;
+	reply_len = ret;
 	ret = -ENOMEM;
 	skb = genlmsg_new(reply_len, GFP_KERNEL);
 	if (!skb)