From owner-freebsd-fs@FreeBSD.ORG Fri Mar 11 19:10:41 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BCAA216A4CE for ; Fri, 11 Mar 2005 19:10:41 +0000 (GMT) Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by mx1.FreeBSD.org (Postfix) with SMTP id B413743D62 for ; Fri, 11 Mar 2005 19:10:40 +0000 (GMT) (envelope-from iedowse@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 11 Mar 2005 19:10:39 +0000 (GMT) To: Sam Leffler In-Reply-To: Your message of "Fri, 11 Mar 2005 09:23:35 PST." <4231D417.9060705@errno.com> Date: Fri, 11 Mar 2005 19:10:38 +0000 From: Ian Dowse Message-ID: <200503111910.aa12186@salmon.maths.tcd.ie> cc: fs@freebsd.org Subject: Re: dirhash potential bug X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Mar 2005 19:10:42 -0000 In message <4231D417.9060705@errno.com>, Sam Leffler writes: >Coverity's analysis tool claims there might be a null bp dereferenced in >ufsdirhash_lookup. Attached is a patch to add a KASSERT but it'd be >good for someone more familiar with the code to check if a change is >required. Sam, maybe you missed my reply to your original message about this? Here it is again anyway. Ian (Message freebsd-commit:11710) -- using template mhl.format -- Date: Thu, 24 Feb 2005 01:32:24 GMT To: Sam Leffler cc: dwmalone@freebsd.org, iedowse@freebsd.org From: Ian Dowse Subject: Re: dirhash potential bug In message <421D0D59.1090001@errno.com>, Sam Leffler writes: >Coverity's analysis tool claims there might be a null bp dereferenced in >ufsdirhash_lookup. Attached is a patch to add a KASSERT but it'd be >good for someone more familiar with the code to check if a change is >required (the analysis tool can be fooled by indirect logic). > >If you commit a change (even this assert) please make sure you mark the >commit with attribution. If this cannot happen please let me know so I >can mark the analysis db I'm going through. Thanks. Hi Sam, As far as I can tell the code is safe as is. Simplified it looks like this: blkoff = -1; bp = NULL; for (...) { offset = non-negative value; if ((offset & ~bmask) != blkoff) bp = non-NULL; [dereference bp] } So it is guaranteed that `((offset & ~bmask) != blkoff)' will be true the first time around the loop and hence bp will be non-NULL. Does that seem ok? Ian