From: David Brownell Subject: Re: [patch 2.6.26-rc3] spi: fix refcount-related spidev oops-on-rmmod Date: Fri, 23 May 2008 23:11:21 -0700 Message-ID: <200805232311.21657.david-b@pacbell.net> References: <200805221348.38163.david-b@pacbell.net> <20080523174814.cd2952c3.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Sebastian Siewior To: Andrew Morton Return-path: In-Reply-To: <20080523174814.cd2952c3.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: spi-devel-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: spi-devel-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: linux-spi.vger.kernel.org On Friday 23 May 2008, Andrew Morton wrote: > On Thu, 22 May 2008 13:48:38 -0700 David Brownell wrote: > > > + /* ... after we unbound from the underlying device? */ > > + spin_lock_irq(&spidev->spi_lock); > > + dofree = (spidev->spi == NULL); > > + spin_unlock_irq(&spidev->spi_lock); > > + > > + if (dofree) > > + kfree(spidev); > > that's very weird-looking code. Just sticking to the locking policy that access to that field is always protected by that lock ... "clearly OK", even if it might be a bit on the overkill side. I'd rather be consistent in that than have to worry about whether, in this one path, it's OK to switch to a different policy since something else ensures that didn't race with spidev_remove(). - Dave ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/