lkml.org 
[lkml]   [2011]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: blkdev_get() change causes OOPS...
On Mon, May 30, 2011 at 10:35:07PM -0700, David Miller wrote:
>
> I don't think whole->bd_disk is guaranteed to be non-NULL where you're
> dereferencing it in blkdev_get() after commit
> d4dc210f69bcb0b4bef5a83b1c323817be89bad1 ("block: don't block events
> on excl write for non-optical devices")

Ah... right, it's there if open succeeded. I should have put the test
after !res test. Does the following patch fix the problem?

Thanks.

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 1f2b199..1a2421f 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1272,8 +1272,8 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder)
* individual writeable reference is too fragile given the
* way @mode is used in blkdev_get/put().
*/
- if ((disk->flags & GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE) &&
- !res && (mode & FMODE_WRITE) && !bdev->bd_write_holder) {
+ if (!res && (mode & FMODE_WRITE) && !bdev->bd_write_holder &&
+ (disk->flags & GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE)) {
bdev->bd_write_holder = true;
disk_block_events(disk);
}


\
 
 \ /
  Last update: 2011-05-31 17:41    [W:0.043 / U:0.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site