Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Jul 1998 14:35:40 +0930
From:      Greg Lehey <grog@lemis.com>
To:        Bruce Evans <bde@zeta.org.au>, cvs-committers@FreeBSD.ORG, julian@FreeBSD.ORG
Subject:   Don't malloc buf headers (was: cvs commit: src/sys/dev/vn vn.c)
Message-ID:  <19980705143540.B18970@freebie.lemis.com>
In-Reply-To: <199807040841.SAA31111@godzilla.zeta.org.au>; from Bruce Evans on Sat, Jul 04, 1998 at 06:41:17PM %2B1000
References:  <199807040841.SAA31111@godzilla.zeta.org.au>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday,  4 July 1998 at 18:41:17 +1000, Bruce Evans wrote:
>>  Modified files:
>>    sys/dev/vn           vn.c
>>  Log:
>>  Don't use a struct buf (malloc'd) without first initialising all the fields
>>  to some known value!
>>  (probable cause of soft updates exploding with vn devices)
>
> Buffers should never be malloced.

This is a problem that has been concerning me for a while, and one
that we have discussed before.  In vinum, I need a buffer structure
with some pointers to other structures internal to vinum.  We've
already agreed that b_driver1 and b_driver2 aren't the way to go
(though I notice that they're still present).  My solution, stolen
from ccd, has been to malloc my own super-bufs with additional fields
at the end.  If this isn't kosher, what method should I use?

> There is no way of knowing how to initialize new fields like b_dep.

Well, I've just checked through the code, and I can see how to
initialize it (for example, LIST_INIT(&cbp->cb_buf.b_dep) in ccd, in
conjunction with a malloced buffer :-), but I can't see it being used.
I can't find anywhere in the sources where it is actually more than
initialized.  I also can't remember seeing anything about it in the
commit messages, and the CVS log for buf.h doesn't mention it.  If I
read the diffs right, it appears to have come from the softupdates
code.  What's it for?  Should I worry in the vinum code, where the
buffers are all internal and have no file system connections?

Greg
--
See complete headers for address and phone numbers
finger grog@lemis.com for PGP public key

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980705143540.B18970>