From f9df0bd2821c302cb13b694842e802cd9e2bc402 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Fri, 21 Oct 2022 11:06:35 +0000 Subject: kernel: fix freeb() for custom pools Some ethernet drivers like ethervt6105M maintain a custom pool of Blocks using Block.free callback. To maintain that Block.list pointer is nil when reused, we have to clear it before returning it to the custom pool as the custom pool code is not aware of it. Also, poison Block.list pointer before free(). --- sys/src/9/port/allocb.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sys/src/9/port') diff --git a/sys/src/9/port/allocb.c b/sys/src/9/port/allocb.c index bb45551eb..cce846cc9 100644 --- a/sys/src/9/port/allocb.c +++ b/sys/src/9/port/allocb.c @@ -107,12 +107,16 @@ freeb(Block *b) * pool of uncached buffers and provide their own free routine. */ if(b->free != nil) { + b->next = nil; + b->list = nil; + b->free(b); return; } /* poison the block in case someone is still holding onto it */ b->next = dead; + b->list = dead; b->rp = dead; b->wp = dead; b->lim = dead; -- cgit v1.2.3