]> git.hungrycats.org Git - linux/commit
[PATCH] raw driver oops fix
authorAndrew Morton <akpm@osdl.org>
Sun, 31 Aug 2003 11:34:53 +0000 (04:34 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Sun, 31 Aug 2003 11:34:53 +0000 (04:34 -0700)
commitab05d4ab09e5256b2cd3f6da448349937069907b
tree00fe5a134d7ca7393bd394122378918cf11ed484
parent1022068badeae0fc73b234efe94fff2fe9fb8546
[PATCH] raw driver oops fix

From: Dave Olien <dmo@osdl.org>

The raw.c character device Oopses dereferencing a NULL pointer in
bd_claim() This problem occurred after bd_claim() in block_dev.c was
modified to "claim the whole device when a partition is claimed".

raw_open() made the mistake of calling bd_claim BEFORE calling blkdev_get().
At that time, the bdev->bd_contains field has not yet been initialized.
Switching the order allows blkdev_get() to initialize those fields before
calling bd_claim().

Also fixed up some error return paths:

igrab() should never fail under these circumstances since the caller
already has a reference to that inode through the bdev at that time.

In the event of blkdev_get() failure or set_blocksize() failure, not all
the work to unwind from the error was done.
drivers/char/raw.c