* [PATCH net-next] ethtool: Remove inactive code snippet in ethtool_set_rxfh_indir
@ 2014-02-18 7:38 Venkata Duvvuru
2014-02-18 22:26 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Venkata Duvvuru @ 2014-02-18 7:38 UTC (permalink / raw)
To: netdev@vger.kernel.org
ethtool_rxfh_indir_default is invoked inside ethtool_get_rxfh_indir when user_size is zero. However user_size can only be zero when dev_size is zero in which case ethtool_get_rxfh_indir itself would have returned -EOPNOTSUPP error. User_size = 0 can never occur unless a buggy ethtool sends user_size as zero beforing invoking the ioctl in which case we should return -EINVAL.
Signed-off-by: Venkat Duvvuru <VenkatKumar.Duvvuru@Emulex.com>
---
net/core/ethtool.c | 33 ++++++++++++++-------------------
1 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 30071de..9d96516 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -626,7 +626,7 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
sizeof(user_size)))
return -EFAULT;
- if (user_size != 0 && user_size != dev_size)
+ if (!user_size || user_size != dev_size)
return -EINVAL;
indir = kcalloc(dev_size, sizeof(indir[0]), GFP_USER); @@ -638,25 +638,20 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
if (ret)
goto out;
- if (user_size == 0) {
- for (i = 0; i < dev_size; i++)
- indir[i] = ethtool_rxfh_indir_default(i, rx_rings.data);
- } else {
- if (copy_from_user(indir,
- useraddr +
- offsetof(struct ethtool_rxfh_indir,
- ring_index[0]),
- dev_size * sizeof(indir[0]))) {
- ret = -EFAULT;
- goto out;
- }
+ if (copy_from_user(indir,
+ useraddr +
+ offsetof(struct ethtool_rxfh_indir,
+ ring_index[0]),
+ dev_size * sizeof(indir[0]))) {
+ ret = -EFAULT;
+ goto out;
+ }
- /* Validate ring indices */
- for (i = 0; i < dev_size; i++) {
- if (indir[i] >= rx_rings.data) {
- ret = -EINVAL;
- goto out;
- }
+ /* Validate ring indices */
+ for (i = 0; i < dev_size; i++) {
+ if (indir[i] >= rx_rings.data) {
+ ret = -EINVAL;
+ goto out;
}
}
--
1.7.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] ethtool: Remove inactive code snippet in ethtool_set_rxfh_indir
2014-02-18 7:38 [PATCH net-next] ethtool: Remove inactive code snippet in ethtool_set_rxfh_indir Venkata Duvvuru
@ 2014-02-18 22:26 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-02-18 22:26 UTC (permalink / raw)
To: VenkatKumar.Duvvuru; +Cc: netdev
From: Venkata Duvvuru <VenkatKumar.Duvvuru@Emulex.Com>
Date: Tue, 18 Feb 2014 07:38:28 +0000
> ethtool_rxfh_indir_default is invoked inside ethtool_get_rxfh_indir when user_size is zero. However user_size can only be zero when dev_size is zero in which case ethtool_get_rxfh_indir itself would have returned -EOPNOTSUPP error. User_size = 0 can never occur unless a buggy ethtool sends user_size as zero beforing invoking the ioctl in which case we should return -EINVAL.
Please properly format your commit message, with newlines every ~80 columns.
> Signed-off-by: Venkat Duvvuru <VenkatKumar.Duvvuru@Emulex.com>
Also your patch was corrupted in transit, look at what happened when it hit
patchwork:
http://patchwork.ozlabs.org/patch/321313/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-18 22:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-18 7:38 [PATCH net-next] ethtool: Remove inactive code snippet in ethtool_set_rxfh_indir Venkata Duvvuru
2014-02-18 22:26 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).