[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1484746445-97920-1-git-send-email-darcari@redhat.com>
Date: Wed, 18 Jan 2017 08:34:05 -0500
From: David Arcari <darcari@...hat.com>
To: netdev@...r.kernel.org
Cc: David Arcari <darcari@...hat.com>
Subject: [PATCH] net: ethtool: avoid allocation failure for dump_regs
If the user executes 'ethtool -d' for an interface and the associated
get_regs_len() function returns 0, the user will see a call trace from
the vmalloc() call in ethtool_get_regs(). This patch modifies
ethtool_get_regs() to avoid the call to vmalloc when the size is zero.
Signed-off-by: David Arcari <darcari@...hat.com>
---
net/core/ethtool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index e23766c..47acd6f 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1405,7 +1405,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
if (regs.len > reglen)
regs.len = reglen;
- regbuf = vzalloc(reglen);
+ regbuf = reglen ? vzalloc(reglen) : NULL;
if (reglen && !regbuf)
return -ENOMEM;
--
Powered by blists - more mailing lists