diff options
-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 b7c12a63d0c..6cdba5fc2be 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) regs.len = reglen; regbuf = vzalloc(reglen); - if (!regbuf) + if (reglen && !regbuf) return -ENOMEM; ops->get_regs(dev, ®s, regbuf); @@ -932,7 +932,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) if (copy_to_user(useraddr, ®s, sizeof(regs))) goto out; useraddr += offsetof(struct ethtool_regs, data); - if (copy_to_user(useraddr, regbuf, regs.len)) + if (regbuf && copy_to_user(useraddr, regbuf, regs.len)) goto out; ret = 0; |