diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2011-07-21 18:25:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-07-21 18:25:30 -0400 |
commit | 67ae7cf1eeda777f79259c4c6cb17a0bd28dee71 (patch) | |
tree | 3644c9018a246df166b220b35d6073efa48a385c /net | |
parent | 1511022c9aabf253253e35730a6a3b945a2a53a9 (diff) |
ethtool: Allow zero-length register dumps again
Some drivers (ab)use the ethtool_ops::get_regs operation to expose
only a hardware revision ID. Commit
a77f5db361ed9953b5b749353ea2c7fed2bf8d93 ('ethtool: Allocate register
dump buffer with vmalloc()') had the side-effect of breaking these, as
vmalloc() returns a null pointer for size=0 whereas kmalloc() did not.
For backward-compatibility, allow zero-length dumps again.
Reported-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Cc: stable@kernel.org [2.6.37+]
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/ethtool.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index b7c12a63d0ce..6cdba5fc2bed 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -923,7 +923,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) | |||
923 | regs.len = reglen; | 923 | regs.len = reglen; |
924 | 924 | ||
925 | regbuf = vzalloc(reglen); | 925 | regbuf = vzalloc(reglen); |
926 | if (!regbuf) | 926 | if (reglen && !regbuf) |
927 | return -ENOMEM; | 927 | return -ENOMEM; |
928 | 928 | ||
929 | ops->get_regs(dev, ®s, regbuf); | 929 | ops->get_regs(dev, ®s, regbuf); |
@@ -932,7 +932,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) | |||
932 | if (copy_to_user(useraddr, ®s, sizeof(regs))) | 932 | if (copy_to_user(useraddr, ®s, sizeof(regs))) |
933 | goto out; | 933 | goto out; |
934 | useraddr += offsetof(struct ethtool_regs, data); | 934 | useraddr += offsetof(struct ethtool_regs, data); |
935 | if (copy_to_user(useraddr, regbuf, regs.len)) | 935 | if (regbuf && copy_to_user(useraddr, regbuf, regs.len)) |
936 | goto out; | 936 | goto out; |
937 | ret = 0; | 937 | ret = 0; |
938 | 938 | ||