linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ide-floppy: Fix unformatted media crash
@ 2007-01-31 17:41 Alan
       [not found] ` <58cb370e0702021351j57c3b559v53741f09acab0b8b@mail.gmail.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Alan @ 2007-01-31 17:41 UTC (permalink / raw)
  To: linux-ide, bzolnier

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.

Signed-off-by: Alan Cox <alan@redhat.com>

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

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
--- linux.vanilla-2.6.20-rc6-mm3/drivers/ide/ide-floppy.c	2007-01-31 14:20:40.000000000 +0000
+++ linux-2.6.20-rc6-mm3/drivers/ide/ide-floppy.c	2007-01-31 14:33:42.000000000 +0000
@@ -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);


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ide-floppy: Fix unformatted media crash
       [not found] ` <58cb370e0702021351j57c3b559v53741f09acab0b8b@mail.gmail.com>
@ 2007-02-02 22:05   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 2+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2007-02-02 22:05 UTC (permalink / raw)
  To: Alan; +Cc: linux-ide


Alan wrote:
> 
> 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.
> 
> Signed-off-by: Alan Cox <alan@redhat.com>

applied, thanks

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-02 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-31 17:41 [PATCH] ide-floppy: Fix unformatted media crash Alan
     [not found] ` <58cb370e0702021351j57c3b559v53741f09acab0b8b@mail.gmail.com>
2007-02-02 22:05   ` Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).