From owner-svn-src-head@FreeBSD.ORG Thu Apr 4 20:57:59 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5B4A1510; Thu, 4 Apr 2013 20:57:59 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) by mx1.freebsd.org (Postfix) with ESMTP id 014A8D1B; Thu, 4 Apr 2013 20:57:57 +0000 (UTC) Received: by mail-ee0-f53.google.com with SMTP id c13so1140977eek.26 for ; Thu, 04 Apr 2013 13:57:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=s2ttozT7A06tv5yGAwpz6r60KKr5UJKZrHwknkpep8c=; b=pcZhcowGcjl6IKZglT3ewi9XFPvfBuqISnIIjeSLS6u6cuxFakgVWauE7DH/QdXAPd qscCPXFHymrjSNrWdQgAmhZyMiXi1eeGn9cUApTJEftCglle186+sC8mi2I5JagD830H VYVcoEG5bK8TdsfGmxUV/NKWoIEeb9LLoA3IGYMkpkK+uWAm53rpad825lntRN8mStrn vS+xa6+6tcycEu0XxLndVbYfciuhQdKvyZfyIP40/XhrsvsdoINgWZuo6sDumim7RdKa jbymXzF1bCskqVs56K46MlAmJzGrMAChKCqwoH/zfVxU4gcVAuvfQ/rCSk+9T0ZYplf7 PaUA== X-Received: by 10.15.35.193 with SMTP id g41mr13719956eev.45.1365109071064; Thu, 04 Apr 2013 13:57:51 -0700 (PDT) Received: from mavbook.mavhome.dp.ua (mavhome.mavhome.dp.ua. [213.227.240.37]) by mx.google.com with ESMTPS id bc1sm12444771eeb.11.2013.04.04.13.57.47 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Apr 2013 13:57:50 -0700 (PDT) Sender: Alexander Motin Message-ID: <515DE949.6050309@FreeBSD.org> Date: Thu, 04 Apr 2013 23:57:45 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130326 Thunderbird/17.0.4 MIME-Version: 1.0 To: Adrian Chadd Subject: Re: svn commit: r249105 - in head/sys/cam: ata scsi References: <201304041904.r34J4F2I065527@svn.freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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: Thu, 04 Apr 2013 20:57:59 -0000 On 04.04.2013 23:53, Adrian Chadd wrote: > Hi, > > Isn't this a prime candidate to replace with KASSERT()? It could be, but NULL dereference attempt will crash system no less reliably then KASSERT. > On 4 April 2013 12:04, Alexander Motin wrote: >> Author: mav >> Date: Thu Apr 4 19:04:15 2013 >> New Revision: 249105 >> URL: http://svnweb.freebsd.org/changeset/base/249105 >> >> Log: >> MFprojects/camlock r248930: >> Remove extra NULL checks. d_drv1 can never be NULL during periph life cycle. >> >> MFC after: 2 weeks >> >> Modified: >> head/sys/cam/ata/ata_da.c >> head/sys/cam/scsi/scsi_cd.c >> head/sys/cam/scsi/scsi_da.c >> >> Modified: head/sys/cam/ata/ata_da.c >> ============================================================================== >> --- head/sys/cam/ata/ata_da.c Thu Apr 4 18:59:29 2013 (r249104) >> +++ head/sys/cam/ata/ata_da.c Thu Apr 4 19:04:15 2013 (r249105) >> @@ -527,10 +527,6 @@ adaopen(struct disk *dp) >> int error; >> >> periph = (struct cam_periph *)dp->d_drv1; >> - if (periph == NULL) { >> - return (ENXIO); >> - } >> - >> if (cam_periph_acquire(periph) != CAM_REQ_CMP) { >> return(ENXIO); >> } >> @@ -566,9 +562,6 @@ adaclose(struct disk *dp) >> union ccb *ccb; >> >> periph = (struct cam_periph *)dp->d_drv1; >> - if (periph == NULL) >> - return (ENXIO); >> - >> cam_periph_lock(periph); >> if (cam_periph_hold(periph, PRIBIO) != 0) { >> cam_periph_unlock(periph); >> @@ -646,10 +639,6 @@ adastrategy(struct bio *bp) >> struct ada_softc *softc; >> >> periph = (struct cam_periph *)bp->bio_disk->d_drv1; >> - if (periph == NULL) { >> - biofinish(bp, NULL, ENXIO); >> - return; >> - } >> softc = (struct ada_softc *)periph->softc; >> >> cam_periph_lock(periph); >> @@ -704,8 +693,6 @@ adadump(void *arg, void *virtual, vm_off >> >> dp = arg; >> periph = dp->d_drv1; >> - if (periph == NULL) >> - return (ENXIO); >> softc = (struct ada_softc *)periph->softc; >> cam_periph_lock(periph); >> secsize = softc->params.secsize; >> @@ -1038,9 +1025,6 @@ adagetattr(struct bio *bp) >> struct cam_periph *periph; >> >> periph = (struct cam_periph *)bp->bio_disk->d_drv1; >> - if (periph == NULL) >> - return (ENXIO); >> - >> cam_periph_lock(periph); >> ret = xpt_getattr(bp->bio_data, bp->bio_length, bp->bio_attribute, >> periph->path); >> >> Modified: head/sys/cam/scsi/scsi_cd.c >> ============================================================================== >> --- head/sys/cam/scsi/scsi_cd.c Thu Apr 4 18:59:29 2013 (r249104) >> +++ head/sys/cam/scsi/scsi_cd.c Thu Apr 4 19:04:15 2013 (r249105) >> @@ -386,7 +386,6 @@ cddiskgonecb(struct disk *dp) >> struct cam_periph *periph; >> >> periph = (struct cam_periph *)dp->d_drv1; >> - >> cam_periph_release(periph); >> } >> >> @@ -1073,9 +1072,6 @@ cdopen(struct disk *dp) >> int error; >> >> periph = (struct cam_periph *)dp->d_drv1; >> - if (periph == NULL) >> - return (ENXIO); >> - >> softc = (struct cd_softc *)periph->softc; >> >> if (cam_periph_acquire(periph) != CAM_REQ_CMP) >> @@ -1120,9 +1116,6 @@ cdclose(struct disk *dp) >> struct cd_softc *softc; >> >> periph = (struct cam_periph *)dp->d_drv1; >> - if (periph == NULL) >> - return (ENXIO); >> - >> softc = (struct cd_softc *)periph->softc; >> >> cam_periph_lock(periph); >> @@ -1473,11 +1466,6 @@ cdstrategy(struct bio *bp) >> struct cd_softc *softc; >> >> periph = (struct cam_periph *)bp->bio_disk->d_drv1; >> - if (periph == NULL) { >> - biofinish(bp, NULL, ENXIO); >> - return; >> - } >> - >> cam_periph_lock(periph); >> CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, >> ("cdstrategy(%p)\n", bp)); >> @@ -1972,9 +1960,6 @@ cdioctl(struct disk *dp, u_long cmd, voi >> int nocopyout, error = 0; >> >> periph = (struct cam_periph *)dp->d_drv1; >> - if (periph == NULL) >> - return(ENXIO); >> - >> cam_periph_lock(periph); >> >> softc = (struct cd_softc *)periph->softc; >> >> Modified: head/sys/cam/scsi/scsi_da.c >> ============================================================================== >> --- head/sys/cam/scsi/scsi_da.c Thu Apr 4 18:59:29 2013 (r249104) >> +++ head/sys/cam/scsi/scsi_da.c Thu Apr 4 19:04:15 2013 (r249105) >> @@ -962,10 +962,6 @@ daopen(struct disk *dp) >> int error; >> >> periph = (struct cam_periph *)dp->d_drv1; >> - if (periph == NULL) { >> - return (ENXIO); >> - } >> - >> if (cam_periph_acquire(periph) != CAM_REQ_CMP) { >> return (ENXIO); >> } >> @@ -1027,9 +1023,6 @@ daclose(struct disk *dp) >> struct da_softc *softc; >> >> periph = (struct cam_periph *)dp->d_drv1; >> - if (periph == NULL) >> - return (0); >> - >> cam_periph_lock(periph); >> if (cam_periph_hold(periph, PRIBIO) != 0) { >> cam_periph_unlock(periph); >> @@ -1118,10 +1111,6 @@ dastrategy(struct bio *bp) >> struct da_softc *softc; >> >> periph = (struct cam_periph *)bp->bio_disk->d_drv1; >> - if (periph == NULL) { >> - biofinish(bp, NULL, ENXIO); >> - return; >> - } >> softc = (struct da_softc *)periph->softc; >> >> cam_periph_lock(periph); >> @@ -1174,8 +1163,6 @@ dadump(void *arg, void *virtual, vm_offs >> >> dp = arg; >> periph = dp->d_drv1; >> - if (periph == NULL) >> - return (ENXIO); >> softc = (struct da_softc *)periph->softc; >> cam_periph_lock(periph); >> secsize = softc->params.secsize; >> @@ -1250,9 +1237,6 @@ dagetattr(struct bio *bp) >> struct cam_periph *periph; >> >> periph = (struct cam_periph *)bp->bio_disk->d_drv1; >> - if (periph == NULL) >> - return (ENXIO); >> - >> cam_periph_lock(periph); >> ret = xpt_getattr(bp->bio_data, bp->bio_length, bp->bio_attribute, >> periph->path); >> @@ -1295,7 +1279,6 @@ dadiskgonecb(struct disk *dp) >> struct cam_periph *periph; >> >> periph = (struct cam_periph *)dp->d_drv1; >> - >> cam_periph_release(periph); >> } >> -- Alexander Motin