summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--net/core/ethtool.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 4a6824767f3d..226d5e1f74d7 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -875,9 +875,12 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
if (regs.len > reglen)
regs.len = reglen;
- regbuf = vzalloc(reglen);
- if (reglen && !regbuf)
- return -ENOMEM;
+ regbuf = NULL;
+ if (reglen) {
+ regbuf = vzalloc(reglen);
+ if (!regbuf)
+ return -ENOMEM;
+ }
ops->get_regs(dev, &regs, regbuf);