Date: 28 Jun 2000 03:58:26 +0200 From: Assar Westerlund <assar@sics.se> To: Marius Bendiksen <mbendiks@eunet.no> Cc: hackers@FreeBSD.ORG Subject: Re: buffer cache question Message-ID: <5lya3qh8hp.fsf@assaris.sics.se> In-Reply-To: Marius Bendiksen's message of "Wed, 28 Jun 2000 02:20:17 %2B0200 (CEST)" References: <Pine.BSF.4.05.10006280215070.14273-100000@login-1.eunet.no>
next in thread | previous in thread | raw e-mail | index | archive | help
Marius Bendiksen <mbendiks@eunet.no> writes:
> In the following code, from /sys/kern/vfs_bio.c : bread(), it appears to
> me that it is possible for a null pointer to be deferenced?
>
> struct buf *bp;
>
> bp = getblk(vp, blkno, size, 0, 0);
> *bpp = bp;
>
> /* if not found in cache, do some I/O */
> if ((bp->b_flags & B_CACHE) == 0) {
>
> It seems, from a very brief inspection of the code, as though getblk()
> might return a null pointer under certain circumstances. I'd expect my
> understanding of the code is flawed, as such a thing should have been
> discovered ages ago, were it a bug, but I feel I should ask.
Not really. getblk can return NULL if the buffer is busy and the
sleep waiting for it time outs. But since slptimeo == 0 in the above
call, tsleep cannot time out. It can also return NULL if getnewbuf
returns NULL and (slpflag || slptimeo) the last of which is always
false in the above call of getblk.
/assar
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5lya3qh8hp.fsf>
