Commit 630c2701 authored by Krzysztof Helt's avatar Krzysztof Helt Committed by Linus Torvalds

hgafb: resource management fix

Release ports which are requested during detection which are not freed if
there is no hga card.  Otherwise there is a crash during cat /proc/ioports
command.
Signed-off-by: default avatarKrzysztof Helt <krzysztof.h1@wp.pl>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 69c5ddf5
...@@ -279,7 +279,7 @@ static void hga_blank(int blank_mode) ...@@ -279,7 +279,7 @@ static void hga_blank(int blank_mode)
static int __init hga_card_detect(void) static int __init hga_card_detect(void)
{ {
int count=0; int count = 0;
void __iomem *p, *q; void __iomem *p, *q;
unsigned short p_save, q_save; unsigned short p_save, q_save;
...@@ -303,20 +303,18 @@ static int __init hga_card_detect(void) ...@@ -303,20 +303,18 @@ static int __init hga_card_detect(void)
writew(0x55aa, p); if (readw(p) == 0x55aa) count++; writew(0x55aa, p); if (readw(p) == 0x55aa) count++;
writew(p_save, p); writew(p_save, p);
if (count != 2) { if (count != 2)
return 0; goto error;
}
/* Ok, there is definitely a card registering at the correct /* Ok, there is definitely a card registering at the correct
* memory location, so now we do an I/O port test. * memory location, so now we do an I/O port test.
*/ */
if (!test_hga_b(0x66, 0x0f)) { /* cursor low register */ if (!test_hga_b(0x66, 0x0f)) /* cursor low register */
return 0; goto error;
}
if (!test_hga_b(0x99, 0x0f)) { /* cursor low register */ if (!test_hga_b(0x99, 0x0f)) /* cursor low register */
return 0; goto error;
}
/* See if the card is a Hercules, by checking whether the vsync /* See if the card is a Hercules, by checking whether the vsync
* bit of the status register is changing. This test lasts for * bit of the status register is changing. This test lasts for
...@@ -331,7 +329,7 @@ static int __init hga_card_detect(void) ...@@ -331,7 +329,7 @@ static int __init hga_card_detect(void)
} }
if (p_save == q_save) if (p_save == q_save)
return 0; goto error;
switch (inb_p(HGA_STATUS_PORT) & 0x70) { switch (inb_p(HGA_STATUS_PORT) & 0x70) {
case 0x10: case 0x10:
...@@ -348,6 +346,12 @@ static int __init hga_card_detect(void) ...@@ -348,6 +346,12 @@ static int __init hga_card_detect(void)
break; break;
} }
return 1; return 1;
error:
if (release_io_ports)
release_region(0x3b0, 12);
if (release_io_port)
release_region(0x3bf, 1);
return 0;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment