Skip to content

Commit

Permalink
block: fix oops on !disk->queue and sysfs discard alignment display
Browse files Browse the repository at this point in the history
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 23ceb5b (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>
  • Loading branch information
Jens Axboe committed May 26, 2011
1 parent 4db70f7 commit f4fa342
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fs/partitions/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,12 @@ ssize_t part_discard_alignment_show(struct device *dev,
{
struct hd_struct *p = dev_to_part(dev);
struct gendisk *disk = dev_to_disk(dev);
unsigned int alignment = 0;

return sprintf(buf, "%u\n",
queue_limit_discard_alignment(&disk->queue->limits,
p->start_sect));
if (disk->queue)
alignment = queue_limit_discard_alignment(&disk->queue->limits,
p->start_sect);
return sprintf(buf, "%u\n", alignment);
}

ssize_t part_stat_show(struct device *dev,
Expand Down

0 comments on commit f4fa342

Please sign in to comment.