From owner-svn-src-head@freebsd.org Wed Feb 8 18:32:54 2017 Return-Path: Delivered-To: svn-src-head@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 CA7FBCD699E; Wed, 8 Feb 2017 18:32:54 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 98A1E1013; Wed, 8 Feb 2017 18:32:54 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v18IWrrx001897; Wed, 8 Feb 2017 18:32:53 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v18IWrIa001896; Wed, 8 Feb 2017 18:32:53 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201702081832.v18IWrIa001896@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Wed, 8 Feb 2017 18:32:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313451 - head/sys/boot/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Feb 2017 18:32:54 -0000 Author: tsoome Date: Wed Feb 8 18:32:53 2017 New Revision: 313451 URL: https://svnweb.freebsd.org/changeset/base/313451 Log: loader: possible NULL pointer dereference in bcache.c Coverity detected the possible NULL pointer dereference case. Also updated comment as was suggested in illumos review. CID: 1371008 Reported by: Coverity Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D9496 Modified: head/sys/boot/common/bcache.c Modified: head/sys/boot/common/bcache.c ============================================================================== --- head/sys/boot/common/bcache.c Wed Feb 8 18:32:35 2017 (r313450) +++ head/sys/boot/common/bcache.c Wed Feb 8 18:32:53 2017 (r313451) @@ -224,13 +224,13 @@ read_strategy(void *devdata, int rw, dad caddr_t p_buf; uint32_t *marker; - marker = (uint32_t *)(bc->bcache_data + bc->bcache_nblks * bcache_blksize); - if (bc == NULL) { errno = ENODEV; return (-1); } + marker = (uint32_t *)(bc->bcache_data + bc->bcache_nblks * bcache_blksize); + if (rsize != NULL) *rsize = 0; @@ -290,10 +290,9 @@ read_strategy(void *devdata, int rw, dad * And secondly, this way we get the most conservative setup for the ra. * * The selection of multiple of 16 blocks (8KB) is quite arbitrary, however, - * we want to have the CD (2K) and the 4K disks to be covered. - * Also, as we have 32 blocks to be allocated as the fallback value in the - * bcache_allocate(), the 16 ra blocks will allow the read ahead - * to be used even with bcache this small. + * we want to cover CDs (2K) and 4K disks. + * bcache_allocate() will always fall back to a minimum of 32 blocks. + * Our choice of 16 read ahead blocks will always fit inside the bcache. */ ra = bc->bcache_nblks - BHASH(bc, p_blk + p_size);