]> git.ipfire.org Git - people/arne_f/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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Apr 2019 06:36:46 +0000 (08:36 +0200)
commit77b924d94dd7a7719933ba9d97a7ba4d19d09d00
tree0ff3e75ea71fc49be102398996f2da872f89eca1
parent6996763856e1fb27ccae260e41fd73a3fff56678
net: ethtool: not call vzalloc for zero sized memory request

[ 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>
net/core/ethtool.c