changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: kernel: fix allocb for BLOCKALIGN*2 >= Hdrspc

changeset 6830: 57cbf6be300b
parent 6829: 9632658d8671
child 6831: 98845adbacea
author: cinap_lenrek@felloff.net
date: Sat, 20 Oct 2018 19:52:54 +0200
files: sys/src/9/port/allocb.c
description: kernel: fix allocb for BLOCKALIGN*2 >= Hdrspc
     1.1--- a/sys/src/9/port/allocb.c
     1.2+++ b/sys/src/9/port/allocb.c
     1.3@@ -19,7 +19,8 @@ static Block*
     1.4 	uintptr addr;
     1.5 
     1.6 	size += Tlrspc;
     1.7-	if((b = mallocz(sizeof(Block)+size+Hdrspc, 0)) == nil)
     1.8+	size = ROUND(size, BLOCKALIGN);
     1.9+	if((b = mallocz(sizeof(Block)+BLOCKALIGN+Hdrspc+size, 0)) == nil)
    1.10 		return nil;
    1.11 
    1.12 	b->next = nil;
    1.13@@ -38,11 +39,8 @@ static Block*
    1.14 	addr &= ~(BLOCKALIGN-1);
    1.15 	b->lim = (uchar*)addr;
    1.16 
    1.17-	/* leave sluff at beginning for added headers */
    1.18-	b->rp = b->lim - ROUND(size, BLOCKALIGN);
    1.19-	if(b->rp < b->base)
    1.20-		panic("_allocb");
    1.21-	b->wp = b->rp;
    1.22+	/* leave room at beginning for added headers */
    1.23+	b->wp = b->rp = b->lim - size;
    1.24 
    1.25 	return b;
    1.26 }