• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

linux-3.0.x for AP-SH4A-0A Board


Commit MetaInfo

Revisão3de8ae6c0d1c0fb73243992adf87c7174028a531 (tree)
Hora2011-08-05 13:58:34
AutorBen Hutchings <bhutchings@sola...>
CommiterGreg Kroah-Hartman

Mensagem de Log

ethtool: Allow zero-length register dumps again

commit 67ae7cf1eeda777f79259c4c6cb17a0bd28dee71 upstream.

Some drivers (ab)use the ethtool_ops::get_regs operation to expose
only a hardware revision ID. Commit
a77f5db361ed9953b5b749353ea2c7fed2bf8d93 ('ethtool: Allocate register
dump buffer with vmalloc()') had the side-effect of breaking these, as
vmalloc() returns a null pointer for size=0 whereas kmalloc() did not.

For backward-compatibility, allow zero-length dumps again.

Reported-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Mudança Sumário

Diff

--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1227,7 +1227,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
12271227 regs.len = reglen;
12281228
12291229 regbuf = vzalloc(reglen);
1230- if (!regbuf)
1230+ if (reglen && !regbuf)
12311231 return -ENOMEM;
12321232
12331233 ops->get_regs(dev, &regs, regbuf);
@@ -1236,7 +1236,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
12361236 if (copy_to_user(useraddr, &regs, sizeof(regs)))
12371237 goto out;
12381238 useraddr += offsetof(struct ethtool_regs, data);
1239- if (copy_to_user(useraddr, regbuf, regs.len))
1239+ if (regbuf && copy_to_user(useraddr, regbuf, regs.len))
12401240 goto out;
12411241 ret = 0;
12421242