public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Fixing the main programmer thinko with the device model
@ 2008-03-24 15:39 James Bottomley
  2008-03-24 17:58 ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: James Bottomley @ 2008-03-24 15:39 UTC (permalink / raw)
  To: Greg KH, Kay Sievers, Van De Ven, Arjan, Al Viro; +Cc: linux-kernel

Having just spent the weekend tracking two separate driver model
problems through SCSI, I believe the biggest trap everyone falls into
with the driver model (well, OK, at least with SCSI) is to try to defer
a callback to the device ->release routine without realising that
somewhere along the callback path we're going to drop a reference to the
device.

You can do this very inadvertently:  One developer didn't realise
bsg_unregister_queue() released a ref, and another didn't realise that
transport_destroy_device() held one.

The real problem is that it's fantastically easy to do this ... it's not
at all clear which of the cleanup routines actually release references
unless you dig down into them and it's very difficult to detect because
all that happens is that devices don't get released when they should,
which isn't something we ever warn about.

So, what I was wondering is:  is there any way we can reliably detect
and warn when someone does this.  Could something like lockdep (although
I can't really see how dynamic detection will work because the device
->release routine is never called) or a static code analysis tool like
sparse be modified to detect the unreleaseable references?

James



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-03-26  5:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-24 15:39 Fixing the main programmer thinko with the device model James Bottomley
2008-03-24 17:58 ` Greg KH
2008-03-24 18:08   ` James Bottomley
2008-03-25  9:57     ` Andi Kleen
2008-03-26  4:16       ` Greg KH
2008-03-26  5:07         ` Kay Sievers
2008-03-26  5:23           ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox