diff options
author | Alan Cox <alan@redhat.com> | 2007-04-04 21:34:22 +0200 |
---|---|---|
committer | Adrian Bunk <bunk@stusta.de> | 2007-04-04 21:34:22 +0200 |
commit | feb26509abe0672e6b56fa4c4765c0e62d4432c3 (patch) | |
tree | c44d3b467fc988a9c6ce87bc4517a071ec73058e /drivers | |
parent | 5f4a9d1b7a413d6aac382c51692ac0df785068c5 (diff) |
ide-floppy: Fix unformatted media crash
A ZIP or similar with unformatted media will cause crashes when attempts
are made to read/write it in some cases. This is because bs_factor is
zero and we divide by it causing an oops.
As the size of a non-accessible/non-existant media is really a bit of a
zen question it doesn't matter if non-existant media is 512 bytes per
sector or zero. Setting it to 1 causes us to generate 512 bytes/sector
accesses and error properly.
Based on a fix found lurking in an ancient bugzilla entry since about 2004 (ugghhh)
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/ide-floppy.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 1f8db9ac05d..0c2625958b7 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -1438,7 +1438,8 @@ static int idefloppy_get_capacity (ide_drive_t *drive) drive->bios_cyl = 0; drive->bios_head = drive->bios_sect = 0; - floppy->blocks = floppy->bs_factor = 0; + floppy->blocks = 0; + floppy->bs_factor = 1; set_capacity(floppy->disk, 0); idefloppy_create_read_capacity_cmd(&pc); |