Skip to content

Commit

Permalink
ide-floppy: Fix unformatted media crash
Browse files Browse the repository at this point in the history
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: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
  • Loading branch information
Alan Cox authored and Bartlomiej Zolnierkiewicz committed Feb 17, 2007
1 parent 39baf8a commit fdb77da
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/ide/ide-floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,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);
Expand Down

0 comments on commit fdb77da

Please sign in to comment.