From: David Arcari <darcari@redhat.com>
To: netdev@vger.kernel.org
Cc: David Arcari <darcari@redhat.com>
Subject: [PATCH] net: ethtool: avoid allocation failure for dump_regs
Date: Wed, 18 Jan 2017 08:34:05 -0500 [thread overview]
Message-ID: <1484746445-97920-1-git-send-email-darcari@redhat.com> (raw)
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;
next reply other threads:[~2017-01-18 13:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-18 13:34 David Arcari [this message]
2017-01-18 16:45 ` [PATCH] net: ethtool: avoid allocation failure for dump_regs 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
[not found] ` <20170119155620.GD6245-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
2017-01-19 18:08 ` Kalle Valo
[not found] ` <87h94uorc1.fsf-HodKDYzPHsUD5k0oWYwrnHL1okKdlPRT@public.gmane.org>
2017-01-19 19:22 ` David Miller
2017-01-20 11:44 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1484746445-97920-1-git-send-email-darcari@redhat.com \
--to=darcari@redhat.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).