diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-03-19 22:34:00 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-21 11:17:24 -0400 |
commit | b125130b22d67f249beba10b71a254558b5279d0 (patch) | |
tree | f42f4f732a2d7920009f34d798d1803def38ea44 /kernel/trace/blktrace.c | |
parent | cd649b8bb830d65c57c3c8b98d57b5402256d8bd (diff) |
blktrace: avoid accessing NULL bdev->bd_disk
bdev->bd_disk can be NULL, if the block device is not opened.
Try this against an unmounted partition, and you'll see NULL dereference:
# echo 1 > /sys/block/sda/sda5/enable
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <49C30098.6080107@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/blktrace.c')
-rw-r--r-- | kernel/trace/blktrace.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index dfee6f915179..108f4f7715a5 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -1362,6 +1362,14 @@ static int blk_str2act_mask(const char *str) | |||
1362 | return mask; | 1362 | return mask; |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | static struct request_queue *blk_trace_get_queue(struct block_device *bdev) | ||
1366 | { | ||
1367 | if (bdev->bd_disk == NULL) | ||
1368 | return NULL; | ||
1369 | |||
1370 | return bdev_get_queue(bdev); | ||
1371 | } | ||
1372 | |||
1365 | static ssize_t sysfs_blk_trace_attr_show(struct device *dev, | 1373 | static ssize_t sysfs_blk_trace_attr_show(struct device *dev, |
1366 | struct device_attribute *attr, | 1374 | struct device_attribute *attr, |
1367 | char *buf) | 1375 | char *buf) |
@@ -1376,9 +1384,10 @@ static ssize_t sysfs_blk_trace_attr_show(struct device *dev, | |||
1376 | if (bdev == NULL) | 1384 | if (bdev == NULL) |
1377 | goto out_unlock_kernel; | 1385 | goto out_unlock_kernel; |
1378 | 1386 | ||
1379 | q = bdev_get_queue(bdev); | 1387 | q = blk_trace_get_queue(bdev); |
1380 | if (q == NULL) | 1388 | if (q == NULL) |
1381 | goto out_bdput; | 1389 | goto out_bdput; |
1390 | |||
1382 | mutex_lock(&bdev->bd_mutex); | 1391 | mutex_lock(&bdev->bd_mutex); |
1383 | 1392 | ||
1384 | if (attr == &dev_attr_enable) { | 1393 | if (attr == &dev_attr_enable) { |
@@ -1435,7 +1444,7 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev, | |||
1435 | if (bdev == NULL) | 1444 | if (bdev == NULL) |
1436 | goto out_unlock_kernel; | 1445 | goto out_unlock_kernel; |
1437 | 1446 | ||
1438 | q = bdev_get_queue(bdev); | 1447 | q = blk_trace_get_queue(bdev); |
1439 | if (q == NULL) | 1448 | if (q == NULL) |
1440 | goto out_bdput; | 1449 | goto out_bdput; |
1441 | 1450 | ||