Skip to contentSkip to conversation

ide-floppy: Fix unformatted media crash

PATCH Applied Alan 2 participants 2 messages Jan 31, 2007 – Feb 2, 2007 1 message not in the archive libata

lore
Share & tools
lore

Alan

author
#0 lore raw

PATCH 1/1 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)

drivers/ide/ide-floppy.c +2 -1
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.20-rc6-mm3/drivers/ide/ide-floppy.c linux-2.6.20-rc6-mm3/drivers/ide/ide-floppy.c
@@ -1434,7 +1434,8 @@
 	
 	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);

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 11 lines · Alan

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.

applied, thanks

Quoted 2 lines

Based on a fix found lurking in an ancient bugzilla entry since about 2004 (ugghhh)