diff options
author | Krzysztof Helt <krzysztof.h1@wp.pl> | 2008-06-12 18:21:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-06-12 21:05:40 -0400 |
commit | 630c270183133ac25bef8c8d726ac448df9b169a (patch) | |
tree | e00d128c2acab7571b43ef013f26a3bff86a57e2 | |
parent | 69c5ddf58a03da3686691ad2f293bc79fd977c10 (diff) |
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: Krzysztof Helt <krzysztof.h1@wp.pl>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/video/hgafb.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/video/hgafb.c b/drivers/video/hgafb.c index fb9e67228543..c18880d9db1f 100644 --- a/drivers/video/hgafb.c +++ b/drivers/video/hgafb.c | |||
@@ -279,7 +279,7 @@ static void hga_blank(int blank_mode) | |||
279 | 279 | ||
280 | static int __init hga_card_detect(void) | 280 | static int __init hga_card_detect(void) |
281 | { | 281 | { |
282 | int count=0; | 282 | int count = 0; |
283 | void __iomem *p, *q; | 283 | void __iomem *p, *q; |
284 | unsigned short p_save, q_save; | 284 | unsigned short p_save, q_save; |
285 | 285 | ||
@@ -303,20 +303,18 @@ static int __init hga_card_detect(void) | |||
303 | writew(0x55aa, p); if (readw(p) == 0x55aa) count++; | 303 | writew(0x55aa, p); if (readw(p) == 0x55aa) count++; |
304 | writew(p_save, p); | 304 | writew(p_save, p); |
305 | 305 | ||
306 | if (count != 2) { | 306 | if (count != 2) |
307 | return 0; | 307 | goto error; |
308 | } | ||
309 | 308 | ||
310 | /* Ok, there is definitely a card registering at the correct | 309 | /* Ok, there is definitely a card registering at the correct |
311 | * memory location, so now we do an I/O port test. | 310 | * memory location, so now we do an I/O port test. |
312 | */ | 311 | */ |
313 | 312 | ||
314 | if (!test_hga_b(0x66, 0x0f)) { /* cursor low register */ | 313 | if (!test_hga_b(0x66, 0x0f)) /* cursor low register */ |
315 | return 0; | 314 | goto error; |
316 | } | 315 | |
317 | if (!test_hga_b(0x99, 0x0f)) { /* cursor low register */ | 316 | if (!test_hga_b(0x99, 0x0f)) /* cursor low register */ |
318 | return 0; | 317 | goto error; |
319 | } | ||
320 | 318 | ||
321 | /* See if the card is a Hercules, by checking whether the vsync | 319 | /* See if the card is a Hercules, by checking whether the vsync |
322 | * bit of the status register is changing. This test lasts for | 320 | * bit of the status register is changing. This test lasts for |
@@ -331,7 +329,7 @@ static int __init hga_card_detect(void) | |||
331 | } | 329 | } |
332 | 330 | ||
333 | if (p_save == q_save) | 331 | if (p_save == q_save) |
334 | return 0; | 332 | goto error; |
335 | 333 | ||
336 | switch (inb_p(HGA_STATUS_PORT) & 0x70) { | 334 | switch (inb_p(HGA_STATUS_PORT) & 0x70) { |
337 | case 0x10: | 335 | case 0x10: |
@@ -348,6 +346,12 @@ static int __init hga_card_detect(void) | |||
348 | break; | 346 | break; |
349 | } | 347 | } |
350 | return 1; | 348 | return 1; |
349 | error: | ||
350 | if (release_io_ports) | ||
351 | release_region(0x3b0, 12); | ||
352 | if (release_io_port) | ||
353 | release_region(0x3bf, 1); | ||
354 | return 0; | ||
351 | } | 355 | } |
352 | 356 | ||
353 | /** | 357 | /** |