From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755366AbbAWNSI (ORCPT ); Fri, 23 Jan 2015 08:18:08 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:42368 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752249AbbAWNSF (ORCPT ); Fri, 23 Jan 2015 08:18:05 -0500 Date: Fri, 23 Jan 2015 05:17:58 -0800 From: Christoph Hellwig To: Rusty Russell Cc: James Bottomley , Masami Hiramatsu , linux-kernel , linux-scsi Subject: Re: module: fix module_refcount() return when running in a module exit routine Message-ID: <20150123131758.GC8045@infradead.org> References: <1421600146.2080.8.camel@HansenPartnership.com> <54BC93C3.7010808@hitachi.com> <878ugzco8c.fsf@rustcorp.com.au> <1421683701.2080.25.camel@HansenPartnership.com> <871tmqcmau.fsf@rustcorp.com.au> <1421774615.2080.88.camel@HansenPartnership.com> <20150122165018.GA27377@infradead.org> <1421946175.2093.1.camel@HansenPartnership.com> <87iofyurzc.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87iofyurzc.fsf@rustcorp.com.au> User-Agent: Mutt/1.5.23 (2014-03-12) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 23, 2015 at 01:24:15PM +1030, Rusty Russell wrote: > The correct fix is to turn try_module_get() into __module_get(), and > always do the module_put(). Is this really safe? __module_get sais it needs a non-zero refcount to start with, but scsi_device_get is the only thing every incrementing the refcount on the module pointer in the scsi host template, so exactly that case can happen easily. There's not assert actually hardcoding the assumption, so I'm not sure if requirement the comment really just is nice to have or a strong requirement.