Marius Bendiksen <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to