From owner-freebsd-hackers Tue Jun 27 18:58:22 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from assaris.sics.se (assaris.sics.se [193.10.66.234]) by hub.freebsd.org (Postfix) with ESMTP id 8365E37C4CF for ; Tue, 27 Jun 2000 18:58:11 -0700 (PDT) (envelope-from assar@assaris.sics.se) Received: (from assar@localhost) by assaris.sics.se (8.9.3/8.9.3) id DAA40909; Wed, 28 Jun 2000 03:58:26 +0200 (CEST) (envelope-from assar) To: Marius Bendiksen Cc: hackers@FreeBSD.ORG Subject: Re: buffer cache question References: From: Assar Westerlund Date: 28 Jun 2000 03:58:26 +0200 In-Reply-To: Marius Bendiksen's message of "Wed, 28 Jun 2000 02:20:17 +0200 (CEST)" Message-ID: <5lya3qh8hp.fsf@assaris.sics.se> Lines: 24 User-Agent: Gnus/5.070098 (Pterodactyl Gnus v0.98) Emacs/20.6 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Marius Bendiksen 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