lkml.org 
[lkml]   [1999]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subjectfloppy.c IRQ/DMA potential bug?
Date
Looking at ftape, there's a patch to floppy.c for versions up through 2.1.x,
and the patch still applies to 2.2.2... It fixes a potential problem where the
IRQ is allocated before the DMA, and if an IRQ from the FDC arrives between
those two, the IRQ handler will try to access the (nonexistent) DMA buffer.

Attached the the patch as it would apply to 2.2.2 -- not sure if it's still
needed.

Taral--- linux/drivers/block/floppy.c.old Sun Jan 10 11:59:59 1999
+++ linux/drivers/block/floppy.c Thu Mar 4 14:43:26 1999
@@ -4240,20 +4240,10 @@ static int floppy_grab_irq_and_dma(void)
}
INT_ON;
MOD_INC_USE_COUNT;
- if (fd_request_irq()) {
- DPRINT("Unable to grab IRQ%d for the floppy driver\n",
- FLOPPY_IRQ);
- MOD_DEC_USE_COUNT;
- usage_count--;
- return -1;
- }
if (fd_request_dma()) {
DPRINT("Unable to grab DMA%d for the floppy driver\n",
FLOPPY_DMA);
- fd_free_irq();
- MOD_DEC_USE_COUNT;
- usage_count--;
- return -1;
+ goto out_no_dma;
}

for (fdc=0; fdc< N_FDC; fdc++){
@@ -4261,15 +4251,7 @@ static int floppy_grab_irq_and_dma(void)
if (check_region(FDCS->address, 6) < 0 ||
check_region(FDCS->address+7, 1) < 0) {
DPRINT("Floppy io-port 0x%04lx in use\n", FDCS->address);
- fd_free_irq();
- fd_free_dma();
- while(--fdc >= 0) {
- release_region(FDCS->address, 6);
- release_region(FDCS->address+7, 1);
- }
- MOD_DEC_USE_COUNT;
- usage_count--;
- return -1;
+ goto release_resources;
}
request_region(FDCS->address, 6, "floppy");
request_region(FDCS->address+7, 1, "floppy DIR");
@@ -4277,6 +4259,11 @@ static int floppy_grab_irq_and_dma(void)
* Unfortunately, Adaptec doesn't know this :-(, */
}
}
+ if (fd_request_irq()) {
+ DPRINT("Unable to grab IRQ%d for the floppy driver\n",
+ FLOPPY_IRQ);
+ goto release_resources;
+ }
for (fdc=0; fdc< N_FDC; fdc++){
if (FDCS->address != -1){
reset_fdc_info(1);
@@ -4296,6 +4283,19 @@ static int floppy_grab_irq_and_dma(void)
fdc = 0;
irqdma_allocated = 1;
return 0;
+
+release_resources:
+ fd_free_dma();
+ while(--fdc >= 0)
+ if (FDCS->address != -1) {
+ release_region(FDCS->address, 6);
+ release_region(FDCS->address+7, 1);
+ }
+ }
+out_no_dma:
+ MOD_DEC_USE_COUNT;
+ usage_count--;
+ return -1;
}

static void floppy_release_irq_and_dma(void)
\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.579 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site