From owner-svn-src-all@freebsd.org Sun Feb 7 16:03:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A20D5AA116F for ; Sun, 7 Feb 2016 16:03:06 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from nm46-vm6.bullet.mail.bf1.yahoo.com (nm46-vm6.bullet.mail.bf1.yahoo.com [216.109.115.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6B0F21358 for ; Sun, 7 Feb 2016 16:03:06 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1454860978; bh=+U8Gu2t/ISqndmXZNejgwTMyI9Ob/xW82L1dm9pvoa0=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject; b=fi9bchJ3zHu2kNehOP+9FRsx2ne37gLZ+qBeRyIhsIWzXnk+fHDedOyBmbvmk8szzMSAqMbQzdBeo3MSDHPbwXfjxEgbWIqW3Ydwv5UxpIZnAVHjsSnuA1KLZNMO5kbBsA8bJgPgvlB0dgGdWlv1BRXxcbcOpESeD+yyUNw169seN7sTrSOtp8h7zRlLxXv4GkWIcbWkqZQWL1fBVvu+i4ydAb6ouhq+r++B2cqjYg8wdr3ZM1ov7KG3IgCJ07cailZBTX510It/GrsYG6CTBBrKKLzrTmWfckX1peaJixbo/wTnx0KYP1QeE5CCBF4qD8Jlp2OMVXHTo//CXjTYBw== Received: from [98.139.170.179] by nm46.bullet.mail.bf1.yahoo.com with NNFMP; 07 Feb 2016 16:02:58 -0000 Received: from [68.142.230.64] by tm22.bullet.mail.bf1.yahoo.com with NNFMP; 07 Feb 2016 16:02:58 -0000 Received: from [127.0.0.1] by smtp221.mail.bf1.yahoo.com with NNFMP; 07 Feb 2016 16:02:58 -0000 X-Yahoo-Newman-Id: 145091.18808.bm@smtp221.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: g8l0FdIVM1kss5rxfxRctgPxWEebQpWdcq59CWjjFbVuGDC YZztZoLcherYJ6xVZzI9a.mDO3_ZhkgoZ2g6_u2pqoVsXpqyLaO0GybV7pc2 vMSZ7hUDfmmfvzyuUE7Y5XudQOg3isQabNv2IvyOzWq7sWLU3mR7r34WoXRx 2T32zNQrEvX8dWcYMHK8DY_dh9ulmmTomzhXGCebHzASdATG20AojG.zqfWQ gU5GLX464YjG0sQtlfqghxLR6gYaEQuNBA.PsSNBRbqLrQFqdUmrUBIPxves n43QmfsRWbhg9a_psqr2KGvuX.0NeWIfdGWkCBi.PhBL4IoU.nfoelXohrR4 wQQt1lJeRbTwJi1c5NIJSPfH2Ayjtc3fscv0TfzrH4914reqvlPuIWvzTZzq HqihN9gsDAGXB2OqdAKmfmw1_r_NW9rNMcJy9nne12M6Eh5cFGD4EYad3VH2 6NUUwwab87h5XnZenK0EmUBWJ9LYtWBxCoGKiLBdVojzSa1sXxMqv0bluUg5 h0EaMH_ur21TnYQVX2g9drzlSt7ZnWAZx X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Subject: Re: svn commit: r295362 - head/sys/fs/cd9660 To: Bruce Evans References: <201602070348.u173meT4000314@repo.freebsd.org> <20160207175356.A867@besplex.bde.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Pedro Giffuni Message-ID: <56B76ABA.8000607@FreeBSD.org> Date: Sun, 7 Feb 2016 11:03:06 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20160207175356.A867@besplex.bde.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2016 16:03:06 -0000 On 02/07/16 02:13, Bruce Evans wrote: > On Sun, 7 Feb 2016, Pedro F. Giffuni wrote: > >> Log: >> cd9660: Drop an unnecessary check for NULL. >> >> This was unnecessary and also confused Coverity. >> >> Confirmed on: NetBSD >> CID: 978558 > > This leaves many similar bugs unfixed nearby. One is a null pointer > panic, not just an unnecessary check. > I admittedly oversimplified the commit log here. Not only the value can't be null, our brelse() also ignores NULL values. From sys/kern/vfs_bio.c: ____ /* * Many function erroneously call brelse with a NULL bp under rare * error conditions. Simply return when called with a NULL bp. */ if (bp == NULL) return; ... ____ And yes, NULL was being misspelled 0 here. I will look at doing more cleanups later. Thanks, Pedro. >> Modified: head/sys/fs/cd9660/cd9660_vfsops.c >> ============================================================================== >> >> --- head/sys/fs/cd9660/cd9660_vfsops.c Sun Feb 7 01:45:24 2016 >> (r295361) >> +++ head/sys/fs/cd9660/cd9660_vfsops.c Sun Feb 7 03:48:40 2016 >> (r295362) >> @@ -741,8 +741,7 @@ cd9660_vget_internal(mp, ino, flags, vpp >> if (off + isonum_711(isodir->length) > >> imp->logical_block_size) { >> vput(vp); >> - if (bp != 0) >> - brelse(bp); >> + brelse(bp); >> printf("fhtovp: directory crosses block boundary >> %d[off=%d/len=%d]\n", >> off +isonum_711(isodir->length), off, >> isonum_711(isodir->length)); >> > > - 11 lines later, there is the same bug in an #if 0 block. > - 9 lines earlier, bp was brelse()ed without a similar check. bp is always > null at that point, so checking for this would be just a style bug. Not > checking, but doing the wrong cleanup of calling brelse() after bread() > fails, gives a null pointer panic in brelse() whenever bread() fails. > > That seems to be all the similar bugs. bp is correctly abused as a flag > later. Other functions depend more critically on bread() setting bp to > NULL when it fails. Typical code is to "goto out" when bread() fails, > and brelse() bp there if it is not null. > > Not-so-similar bugs include spelling NULL as 0 or (empty). > > bread(9) is undocumented. Someone broke its KPI by changing it to a > macro. This annoys me when I try to set a breakpoint at it in kernels > with the broken KPI. The unimportant badly designed bread(3) is > documented. > > Bruce