]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
net: ethtool: not call vzalloc for zero sized memory request
authorLi RongQing <lirongqing@baidu.com>
Fri, 29 Mar 2019 01:18:02 +0000 (09:18 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit15354eb498496721553aa5a1c17449db122720ac
tree4e1d94973c7b29e0b65233abd23a5dd3e1fa1d60
parent1d532ad3c6ef04e55d3d923a225a3c44324fb1c4
net: ethtool: not call vzalloc for zero sized memory request

BugLink: https://bugs.launchpad.net/bugs/1838116
[ Upstream commit 3d8830266ffc28c16032b859e38a0252e014b631 ]

NULL or ZERO_SIZE_PTR will be returned for zero sized memory
request, and derefencing them will lead to a segfault

so it is unnecessory to call vzalloc for zero sized memory
request and not call functions which maybe derefence the
NULL allocated memory

this also fixes a possible memory leak if phy_ethtool_get_stats
returns error, memory should be freed before exit

Signed-off-by: Li RongQing <lirongqing@baidu.com>
Reviewed-by: Wang Li <wangli39@baidu.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/core/ethtool.c