Fix the freeing code for some error paths. Found and tested by Patrick Welche.
This commit is contained in:
parent
85760d7e91
commit
e9ddeea551
@ -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 @@ err_tx_desc:
|
||||
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 */
|
||||
|
@ -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 @@ ixgbe_attach(device_t parent, device_t dev, void *aux)
|
||||
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 @@ ixgbe_attach(device_t parent, device_t dev, void *aux)
|
||||
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 @@ ixgbe_detach(device_t dev, int flags)
|
||||
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);
|
||||
|
@ -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_deferred_mq_start_work(struct work *, void *);
|
||||
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 *);
|
||||
|
@ -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_jcl_destroy(struct adapter *adapter, struct rx_ring *rxr)
|
||||
{
|
||||
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);
|
||||
|
||||
mutex_destroy(&eh->eh_mtx);
|
||||
eh->eh_initialized = false;
|
||||
}
|
||||
|
@ -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 @@ ixv_attach(device_t parent, device_t dev, void *aux)
|
||||
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 @@ ixv_detach(device_t dev, int flags)
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user