All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: ethtool: avoid allocation failure for dump_regs
@ 2017-01-18 13:34 David Arcari
  2017-01-18 16:45 ` David Miller
  0 siblings, 1 reply; 10+ messages in thread
From: David Arcari @ 2017-01-18 13:34 UTC (permalink / raw)
  To: netdev; +Cc: David Arcari

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@redhat.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;
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-01-20 11:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-18 13:34 [PATCH] net: ethtool: avoid allocation failure for dump_regs David Arcari
2017-01-18 16:45 ` David Miller
2017-01-19 12:35   ` David Arcari
2017-01-19 14:15     ` John W. Linville
2017-01-19 15:56       ` John W. Linville
2017-01-19 18:08         ` Kalle Valo
2017-01-19 18:08           ` Kalle Valo
2017-01-19 19:22           ` David Miller
2017-01-19 19:22             ` David Miller
2017-01-20 11:44             ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.