* [PATCH v2] hv_netvsc: fix a possible NULL pointer dereference in netvsc_get_ethtool_stats()
@ 2019-03-12 5:01 Kangjie Lu
2019-03-13 21:08 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-03-12 5:01 UTC (permalink / raw)
To: kjlu
Cc: pakki001, K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger,
Sasha Levin, David S. Miller, linux-hyperv, netdev, linux-kernel
In case kvmalloc_array fails, we should stop using it to avoid
NULL pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/net/hyperv/netvsc_drv.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index cf4897043e83..4b3a03029fe8 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1426,6 +1426,9 @@ static void netvsc_get_ethtool_stats(struct net_device *dev,
pcpu_sum = kvmalloc_array(num_possible_cpus(),
sizeof(struct netvsc_ethtool_pcpu_stats),
GFP_KERNEL);
+ if (!pcpu_sum)
+ return;
+
netvsc_get_pcpu_stats(dev, pcpu_sum);
for_each_present_cpu(cpu) {
struct netvsc_ethtool_pcpu_stats *this_sum = &pcpu_sum[cpu];
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] hv_netvsc: fix a possible NULL pointer dereference in netvsc_get_ethtool_stats()
2019-03-12 5:01 [PATCH v2] hv_netvsc: fix a possible NULL pointer dereference in netvsc_get_ethtool_stats() Kangjie Lu
@ 2019-03-13 21:08 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-03-13 21:08 UTC (permalink / raw)
To: kjlu
Cc: pakki001, kys, haiyangz, sthemmin, sashal, linux-hyperv, netdev,
linux-kernel
From: Kangjie Lu <kjlu@umn.edu>
Date: Tue, 12 Mar 2019 00:01:49 -0500
> In case kvmalloc_array fails, we should stop using it to avoid
> NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/hyperv/netvsc_drv.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
> index cf4897043e83..4b3a03029fe8 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -1426,6 +1426,9 @@ static void netvsc_get_ethtool_stats(struct net_device *dev,
> pcpu_sum = kvmalloc_array(num_possible_cpus(),
> sizeof(struct netvsc_ethtool_pcpu_stats),
> GFP_KERNEL);
> + if (!pcpu_sum)
> + return;
> +
> netvsc_get_pcpu_stats(dev, pcpu_sum);
> for_each_present_cpu(cpu) {
> struct netvsc_ethtool_pcpu_stats *this_sum = &pcpu_sum[cpu];
What a surprise it will be when the user's statistics monitoring
software sees values suddenly drop to zero with no error indication
whatsoever.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-13 21:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12 5:01 [PATCH v2] hv_netvsc: fix a possible NULL pointer dereference in netvsc_get_ethtool_stats() Kangjie Lu
2019-03-13 21:08 ` David Miller
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).