summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcem <cem@FreeBSD.org>2015-10-11 20:59:02 +0000
committercem <cem@FreeBSD.org>2015-10-11 20:59:02 +0000
commit37418275e11b42a28ca998b72bb5929dd1c4a53c (patch)
tree44ac996c801df28bbb07869a74b51041d66b34c9
parent393effa336979c40469fd745db0dc84f70c1cb00 (diff)
downloadFreeBSD-src-37418275e11b42a28ca998b72bb5929dd1c4a53c.zip
FreeBSD-src-37418275e11b42a28ca998b72bb5929dd1c4a53c.tar.gz
NTB: MFV b77b2637: Link toggle memory leak
Each link-up will allocate a new NTB receive buffer when the NTB properties are negotiated with the remote system. These allocations did not check for existing buffers and thus did not free them. Now, the driver will check for an existing buffer and free it if not of the correct size, before trying to alloc a new one. Authored by: Jon Mason Obtained from: Linux Sponsored by: EMC / Isilon Storage Division
-rw-r--r--sys/dev/ntb/if_ntb/if_ntb.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/dev/ntb/if_ntb/if_ntb.c b/sys/dev/ntb/if_ntb/if_ntb.c
index 101691d..09c1736 100644
--- a/sys/dev/ntb/if_ntb/if_ntb.c
+++ b/sys/dev/ntb/if_ntb/if_ntb.c
@@ -1129,12 +1129,20 @@ ntb_set_mw(struct ntb_netdev *nt, int num_mw, unsigned int size)
{
struct ntb_transport_mw *mw = &nt->mw[num_mw];
+ /* No need to re-setup */
+ if (mw->size == size)
+ return (0);
+
+ if (mw->size != 0)
+ ntb_free_mw(nt, num_mw);
+
/* Alloc memory for receiving data. Must be 4k aligned */
mw->size = size;
mw->virt_addr = contigmalloc(mw->size, M_NTB_IF, M_ZERO, 0,
BUS_SPACE_MAXADDR, mw->size, 0);
if (mw->virt_addr == NULL) {
+ mw->size = 0;
printf("ntb: Unable to allocate MW buffer of size %d\n",
(int)mw->size);
return (ENOMEM);
OpenPOWER on IntegriCloud