From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 26 10:18:30 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0FDD3106564A for ; Tue, 26 Apr 2011 10:18:30 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe03.c2i.net [212.247.154.66]) by mx1.freebsd.org (Postfix) with ESMTP id 997438FC1E for ; Tue, 26 Apr 2011 10:18:29 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.1 cv=0KkIQGagYCvnrzE3Z2Lmid87OPdbX6VLcZYwAuLMZ50= c=1 sm=1 a=SvYTsOw2Z4kA:10 a=NSgU13EpIVMA:10 a=WQU8e4WWZSUA:10 a=IkcTkHD0fZMA:10 a=CL8lFSKtTFcA:10 a=i9M/sDlu2rpZ9XS819oYzg==:17 a=Lt6ckGUMipCv9aN9IDUA:9 a=QEXdDO2ut3YA:10 a=i9M/sDlu2rpZ9XS819oYzg==:117 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe03.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 118961641; Tue, 26 Apr 2011 12:18:20 +0200 From: Hans Petter Selasky To: freebsd-hackers@freebsd.org Date: Tue, 26 Apr 2011 12:17:23 +0200 User-Agent: KMail/1.13.5 (FreeBSD/8.2-STABLE; KDE/4.4.5; amd64; ; ) References: <4DB695DB.1080505@chillt.de> In-Reply-To: <4DB695DB.1080505@chillt.de> X-Face: *nPdTl_}RuAI6^PVpA02T?$%Xa^>@hE0uyUIoiha$pC:9TVgl.Oq,NwSZ4V" =?iso-8859-1?q?=7CLR=2E+tj=7Dg5=0A=09=25V?=,x^qOs~mnU3]Gn; cQLv&.N>TrxmSFf+p6(30a/{)KUU!s}w\IhQBj}[g}bj0I3^glmC( =?iso-8859-1?q?=0A=09=3AAuzV9=3A=2EhESm-x4h240C=609=3Dw?= MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201104261217.23858.hselasky@c2i.net> Cc: Bartosz Fabianowski Subject: Re: Is there some implicit locking of device methods? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2011 10:18:30 -0000 On Tuesday 26 April 2011 11:52:27 Bartosz Fabianowski wrote: > 1. attach() is running and executes make_dev(). Before attach() has > finished, someone calls open() on the newly created device node and > tries to read from a device that is not fully instantiated. > > 2. read() is running when the device is suddenly pulled (this is a USB > device) so that detach() gets run. Thus, detach() starts tearing down > data structures that read() may still be accessing. Hi, You need to handle all cases in your driver. Fortunately there exists a solution for this already, called USB cdev. See serial/ulpt.c for example. --HPS