All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] aquantia: Fix "ethtool -S" crash when adapter down.
@ 2017-05-04 16:33 Pavel Belous
  2017-05-04 16:48 ` Lino Sanfilippo
  2017-05-04 17:00 ` David Arcari
  0 siblings, 2 replies; 15+ messages in thread
From: Pavel Belous @ 2017-05-04 16:33 UTC (permalink / raw)
  To: David S . Miller; +Cc: netdev, David Arcari

From: Pavel Belous <pavel.belous@aquantia.com>

This patch fixes the crash that happens when driver tries to collect statistics
from already released "aq_vec" object.

Fixes: 97bde5c4f909 ("net: ethernet: aquantia: Support for NIC-specific code")
Signed-off-by: Pavel Belous <pavel.belous@aquantia.com>
---
 drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index cdb0299..3a32573 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -755,7 +755,7 @@ void aq_nic_get_stats(struct aq_nic_s *self, u64 *data)
 	count = 0U;
 
 	for (i = 0U, aq_vec = self->aq_vec[0];
-		self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i]) {
+		aq_vec && self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i]) {
 		data += count;
 		aq_vec_get_sw_stats(aq_vec, data, &count);
 	}
@@ -961,6 +961,7 @@ void aq_nic_free_hot_resources(struct aq_nic_s *self)
 	for (i = AQ_DIMOF(self->aq_vec); i--;) {
 		if (self->aq_vec[i])
 			aq_vec_free(self->aq_vec[i]);
+			self->aq_vec[i] = NULL;
 	}
 
 err_exit:;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [PATCH] aquantia: Fix "ethtool -S" crash when adapter down.
@ 2017-05-04 20:10 Pavel Belous
  2017-05-04 20:30 ` Joe Perches
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Pavel Belous @ 2017-05-04 20:10 UTC (permalink / raw)
  To: David S . Miller; +Cc: netdev, David Arcari, Lino Sanfilippo, Simon Edelhaus

From: Pavel Belous <pavel.belous@aquantia.com>

This patch fixes the crash that happens when driver tries to collect statistics
from already released "aq_vec" object.
If adapter is in "down" state we still allow user to see statistics from HW.

V2: fixed braces around "aq_vec_free".

Fixes: 97bde5c4f909 ("net: ethernet: aquantia: Support for NIC-specific code")
Signed-off-by: Pavel Belous <pavel.belous@aquantia.com>
---
 drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index cdb0299..9ee1c50 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -755,7 +755,7 @@ void aq_nic_get_stats(struct aq_nic_s *self, u64 *data)
 	count = 0U;
 
 	for (i = 0U, aq_vec = self->aq_vec[0];
-		self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i]) {
+		aq_vec && self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i]) {
 		data += count;
 		aq_vec_get_sw_stats(aq_vec, data, &count);
 	}
@@ -959,8 +959,10 @@ void aq_nic_free_hot_resources(struct aq_nic_s *self)
 		goto err_exit;
 
 	for (i = AQ_DIMOF(self->aq_vec); i--;) {
-		if (self->aq_vec[i])
+		if (self->aq_vec[i]) {
 			aq_vec_free(self->aq_vec[i]);
+			self->aq_vec[i] = NULL;
+		}
 	}
 
 err_exit:;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-05-08 16:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-04 16:33 [PATCH] aquantia: Fix "ethtool -S" crash when adapter down Pavel Belous
2017-05-04 16:48 ` Lino Sanfilippo
2017-05-04 16:51   ` David Miller
2017-05-04 17:09     ` Pavel Belous
2017-05-04 18:27       ` David Arcari
2017-05-04 18:37         ` Pavel Belous
2017-05-04 19:08           ` Lino Sanfilippo
2017-05-04 17:00 ` David Arcari
2017-05-04 17:08   ` Pavel Belous
2017-05-04 18:17     ` Joe Perches
2017-05-04 18:41       ` Pavel Belous
2017-05-04 20:10 Pavel Belous
2017-05-04 20:30 ` Joe Perches
2017-05-04 20:39 ` David Arcari
2017-05-08 16:53 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.