From owner-freebsd-scsi Tue Dec 10 13:29:56 2002 Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CA11B37B401 for ; Tue, 10 Dec 2002 13:29:54 -0800 (PST) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 351C243EC2 for ; Tue, 10 Dec 2002 13:29:54 -0800 (PST) (envelope-from nate@rootlabs.com) Received: (qmail 28515 invoked by uid 1000); 10 Dec 2002 21:29:55 -0000 Date: Tue, 10 Dec 2002 13:29:55 -0800 (PST) From: Nate Lawson To: Yar Tikhiy Cc: "Kenneth D. Merry" , freebsd-scsi@FreeBSD.ORG Subject: Re: {da,sa,...}open bug? In-Reply-To: <20021210171528.B27181@comp.chem.msu.su> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-scsi@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Tue, 10 Dec 2002, Yar Tikhiy wrote: > On Mon, Dec 09, 2002 at 01:50:14PM -0800, Nate Lawson wrote: > > NULL check should be moved inside the splsoftcam to ensure exclusive > > access. In the future, we'll use mutex(9) for implementing lock and > > acquire. > > > > --- /sys/cam/cam_periph.c 14 Nov 2002 05:35:57 -0000 1.43 > > +++ /sys/cam/cam_periph.c 9 Dec 2002 21:38:02 -0000 > > @@ -262,15 +262,17 @@ > > cam_periph_acquire(struct cam_periph *periph) > > { > > int s; > > + cam_status status; > > > > - if (periph == NULL) > > - return(CAM_REQ_CMP_ERR); > > - > > + cam_status = CAM_REQ_CMP; > > s = splsoftcam(); > > - periph->refcount++; > > + if (periph != NULL) > > + periph->refcount++; > > + else > > + status = CAM_REQ_CMP_ERR; > > splx(s); > > > > - return(CAM_REQ_CMP); > > + return (status); > > } > > > > void > > Excuse me, but I see little reason in this patch. "periph" is a > function argument, so its value cannot be changed anywhere else, > so there is no need for splsoftcam() before the NULL check. I guess this makes sense since it's too late by the point where *periph has been pushed on the stack and acquire called. My concern was the (very small) possibility that between the NULL check and refcount++, an interrupt could happen and free the periph. But my patch does not fix this, as you point out. -Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message