diff options
author | Jens Axboe <jaxboe@fusionio.com> | 2011-05-26 15:01:38 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2011-05-26 15:01:38 -0400 |
commit | f4fa3424c66255ba1e07b26becfc3d6cab0fdf65 (patch) | |
tree | 7c16496c0f87bc4f1236c08e264065c776baec73 /fs/partitions/check.c | |
parent | 4db70f73e56961b9bcdfd0c36c62847a18b7dbb5 (diff) |
block: fix oops on !disk->queue and sysfs discard alignment display
Eric Dumazet reports:
----
At boot, I have a crash in part_discard_alignment_show+0x1b/0x50
CR2 : 000006ac
fault in : mov 0x2c(%rcx),%edx
I suspect commit 23ceb5b7719e9276d4 (block: Remove extra
discard_alignment from hd_struct) being in fault
----
Not quite known how ->queue can be NULL while the sysfs entry
exists, but lets play it safe and check for a NULL queue.
The rest of the sysfs show strategies in check.c do not dereference
disk->queue.
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'fs/partitions/check.c')
-rw-r--r-- | fs/partitions/check.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 8ed4d3433199..f82e762eeca2 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -256,10 +256,12 @@ ssize_t part_discard_alignment_show(struct device *dev, | |||
256 | { | 256 | { |
257 | struct hd_struct *p = dev_to_part(dev); | 257 | struct hd_struct *p = dev_to_part(dev); |
258 | struct gendisk *disk = dev_to_disk(dev); | 258 | struct gendisk *disk = dev_to_disk(dev); |
259 | unsigned int alignment = 0; | ||
259 | 260 | ||
260 | return sprintf(buf, "%u\n", | 261 | if (disk->queue) |
261 | queue_limit_discard_alignment(&disk->queue->limits, | 262 | alignment = queue_limit_discard_alignment(&disk->queue->limits, |
262 | p->start_sect)); | 263 | p->start_sect); |
264 | return sprintf(buf, "%u\n", alignment); | ||
263 | } | 265 | } |
264 | 266 | ||
265 | ssize_t part_stat_show(struct device *dev, | 267 | ssize_t part_stat_show(struct device *dev, |