Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci/ixgbe Fix the freeing code for some error paths....
details: https://anonhg.NetBSD.org/src/rev/d9c0eb534d85
branches: trunk
changeset: 848227:d9c0eb534d85
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Tue Jan 21 14:55:55 2020 +0000
description:
Fix the freeing code for some error paths. Found and tested by Patrick Welche.
diffstat:
sys/dev/pci/ixgbe/ix_txrx.c | 23 ++++++++++++++++++++++-
sys/dev/pci/ixgbe/ixgbe.c | 18 ++++--------------
sys/dev/pci/ixgbe/ixgbe.h | 3 ++-
sys/dev/pci/ixgbe/ixgbe_netbsd.c | 8 ++++----
sys/dev/pci/ixgbe/ixv.c | 14 +++-----------
5 files changed, 35 insertions(+), 31 deletions(-)
diffs (155 lines):
diff -r f373fd01b4e9 -r d9c0eb534d85 sys/dev/pci/ixgbe/ix_txrx.c
--- a/sys/dev/pci/ixgbe/ix_txrx.c Tue Jan 21 11:48:10 2020 +0000
+++ b/sys/dev/pci/ixgbe/ix_txrx.c Tue Jan 21 14:55:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.59 2020/01/20 07:19:04 msaitoh Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.60 2020/01/21 14:55:55 msaitoh Exp $ */
/******************************************************************************
@@ -2353,3 +2353,24 @@
free(adapter->queues, M_DEVBUF);
return (error);
} /* ixgbe_allocate_queues */
+
+/************************************************************************
+ * ixgbe_free_queues
+ *
+ * Free descriptors for the transmit and receive rings, and then
+ * the memory associated with each.
+ ************************************************************************/
+void
+ixgbe_free_queues(struct adapter *adapter)
+{
+ struct ix_queue *que;
+ int i;
+
+ ixgbe_free_transmit_structures(adapter);
+ ixgbe_free_receive_structures(adapter);
+ for (i = 0; i < adapter->num_queues; i++) {
+ que = &adapter->queues[i];
+ mutex_destroy(&que->dc_mtx);
+ }
+ free(adapter->queues, M_DEVBUF);
+} /* ixgbe_free_queues */
diff -r f373fd01b4e9 -r d9c0eb534d85 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Tue Jan 21 11:48:10 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Tue Jan 21 14:55:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.220 2020/01/03 12:59:46 pgoyette Exp $ */
+/* $NetBSD: ixgbe.c,v 1.221 2020/01/21 14:55:55 msaitoh Exp $ */
/******************************************************************************
@@ -1059,9 +1059,7 @@
error = ixgbe_allocate_msix(adapter, pa);
if (error) {
/* Free allocated queue structures first */
- ixgbe_free_transmit_structures(adapter);
- ixgbe_free_receive_structures(adapter);
- free(adapter->queues, M_DEVBUF);
+ ixgbe_free_queues(adapter);
/* Fallback to legacy interrupt */
adapter->feat_en &= ~IXGBE_FEATURE_MSIX;
@@ -1236,9 +1234,7 @@
return;
err_late:
- ixgbe_free_transmit_structures(adapter);
- ixgbe_free_receive_structures(adapter);
- free(adapter->queues, M_DEVBUF);
+ ixgbe_free_queues(adapter);
err_out:
ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT);
ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD;
@@ -3712,13 +3708,7 @@
evcnt_detach(&stats->ptc1023);
evcnt_detach(&stats->ptc1522);
- ixgbe_free_transmit_structures(adapter);
- ixgbe_free_receive_structures(adapter);
- for (i = 0; i < adapter->num_queues; i++) {
- struct ix_queue * que = &adapter->queues[i];
- mutex_destroy(&que->dc_mtx);
- }
- free(adapter->queues, M_DEVBUF);
+ ixgbe_free_queues(adapter);
free(adapter->mta, M_DEVBUF);
IXGBE_CORE_LOCK_DESTROY(adapter);
diff -r f373fd01b4e9 -r d9c0eb534d85 sys/dev/pci/ixgbe/ixgbe.h
--- a/sys/dev/pci/ixgbe/ixgbe.h Tue Jan 21 11:48:10 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.h Tue Jan 21 14:55:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.61 2020/01/20 07:19:04 msaitoh Exp $ */
+/* $NetBSD: ixgbe.h,v 1.62 2020/01/21 14:55:55 msaitoh Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@@ -768,6 +768,7 @@
void ixgbe_drain_all(struct adapter *);
int ixgbe_allocate_queues(struct adapter *);
+void ixgbe_free_queues(struct adapter *);
int ixgbe_setup_transmit_structures(struct adapter *);
void ixgbe_free_transmit_structures(struct adapter *);
int ixgbe_setup_receive_structures(struct adapter *);
diff -r f373fd01b4e9 -r d9c0eb534d85 sys/dev/pci/ixgbe/ixgbe_netbsd.c
--- a/sys/dev/pci/ixgbe/ixgbe_netbsd.c Tue Jan 21 11:48:10 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_netbsd.c Tue Jan 21 14:55:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_netbsd.c,v 1.11 2020/01/20 07:19:04 msaitoh Exp $ */
+/* $NetBSD: ixgbe_netbsd.c,v 1.12 2020/01/21 14:55:55 msaitoh Exp $ */
/*
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -225,10 +225,10 @@
{
ixgbe_extmem_head_t *eh = &rxr->jcl_head;
- /* Free all dmamem */
- ixgbe_jcl_freeall(adapter, rxr);
+ if (eh->eh_initialized) {
+ /* Free all dmamem */
+ ixgbe_jcl_freeall(adapter, rxr);
- if (eh->eh_initialized) {
mutex_destroy(&eh->eh_mtx);
eh->eh_initialized = false;
}
diff -r f373fd01b4e9 -r d9c0eb534d85 sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c Tue Jan 21 11:48:10 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c Tue Jan 21 14:55:55 2020 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.143 2019/12/17 05:49:01 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.144 2020/01/21 14:55:55 msaitoh Exp $*/
/******************************************************************************
@@ -547,9 +547,7 @@
return;
err_late:
- ixgbe_free_transmit_structures(adapter);
- ixgbe_free_receive_structures(adapter);
- free(adapter->queues, M_DEVBUF);
+ ixgbe_free_queues(adapter);
err_out:
ixv_free_pci_resources(adapter);
IXGBE_CORE_LOCK_DESTROY(adapter);
@@ -674,13 +672,7 @@
evcnt_detach(&hw->mbx.stats.reqs);
evcnt_detach(&hw->mbx.stats.rsts);
- ixgbe_free_transmit_structures(adapter);
- ixgbe_free_receive_structures(adapter);
- for (int i = 0; i < adapter->num_queues; i++) {
- struct ix_queue *lque = &adapter->queues[i];
- mutex_destroy(&lque->dc_mtx);
- }
- free(adapter->queues, M_DEVBUF);
+ ixgbe_free_queues(adapter);
IXGBE_CORE_LOCK_DESTROY(adapter);
Home |
Main Index |
Thread Index |
Old Index