]>
Commit | Line | Data |
---|---|---|
20bb7f08 GKH |
1 | From stable-bounces@linux.kernel.org Thu Jun 12 19:40:46 2008 |
2 | From: Krzysztof Helt <krzysztof.h1@wp.pl> | |
3 | Date: Fri, 13 Jun 2008 02:40:28 GMT | |
4 | Subject: hgafb: resource management fix | |
5 | To: jejb@kernel.org, stable@kernel.org | |
6 | Message-ID: <200806130240.m5D2eSbU031209@hera.kernel.org> | |
7 | ||
8 | From: Krzysztof Helt <krzysztof.h1@wp.pl> | |
9 | ||
10 | commit 630c270183133ac25bef8c8d726ac448df9b169a upstream | |
11 | Date: Thu, 12 Jun 2008 15:21:29 -0700 | |
12 | Subject: hgafb: resource management fix | |
13 | ||
14 | Release ports which are requested during detection which are not freed if | |
15 | there is no hga card. Otherwise there is a crash during cat /proc/ioports | |
16 | command. | |
17 | ||
18 | Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> | |
19 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | |
20 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
21 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
22 | ||
23 | --- | |
24 | drivers/video/hgafb.c | 26 +++++++++++++++----------- | |
25 | 1 file changed, 15 insertions(+), 11 deletions(-) | |
26 | ||
27 | --- a/drivers/video/hgafb.c | |
28 | +++ b/drivers/video/hgafb.c | |
29 | @@ -279,7 +279,7 @@ static void hga_blank(int blank_mode) | |
30 | ||
31 | static int __init hga_card_detect(void) | |
32 | { | |
33 | - int count=0; | |
34 | + int count = 0; | |
35 | void __iomem *p, *q; | |
36 | unsigned short p_save, q_save; | |
37 | ||
38 | @@ -303,20 +303,18 @@ static int __init hga_card_detect(void) | |
39 | writew(0x55aa, p); if (readw(p) == 0x55aa) count++; | |
40 | writew(p_save, p); | |
41 | ||
42 | - if (count != 2) { | |
43 | - return 0; | |
44 | - } | |
45 | + if (count != 2) | |
46 | + goto error; | |
47 | ||
48 | /* Ok, there is definitely a card registering at the correct | |
49 | * memory location, so now we do an I/O port test. | |
50 | */ | |
51 | ||
52 | - if (!test_hga_b(0x66, 0x0f)) { /* cursor low register */ | |
53 | - return 0; | |
54 | - } | |
55 | - if (!test_hga_b(0x99, 0x0f)) { /* cursor low register */ | |
56 | - return 0; | |
57 | - } | |
58 | + if (!test_hga_b(0x66, 0x0f)) /* cursor low register */ | |
59 | + goto error; | |
60 | + | |
61 | + if (!test_hga_b(0x99, 0x0f)) /* cursor low register */ | |
62 | + goto error; | |
63 | ||
64 | /* See if the card is a Hercules, by checking whether the vsync | |
65 | * bit of the status register is changing. This test lasts for | |
66 | @@ -331,7 +329,7 @@ static int __init hga_card_detect(void) | |
67 | } | |
68 | ||
69 | if (p_save == q_save) | |
70 | - return 0; | |
71 | + goto error; | |
72 | ||
73 | switch (inb_p(HGA_STATUS_PORT) & 0x70) { | |
74 | case 0x10: | |
75 | @@ -348,6 +346,12 @@ static int __init hga_card_detect(void) | |
76 | break; | |
77 | } | |
78 | return 1; | |
79 | +error: | |
80 | + if (release_io_ports) | |
81 | + release_region(0x3b0, 12); | |
82 | + if (release_io_port) | |
83 | + release_region(0x3bf, 1); | |
84 | + return 0; | |
85 | } | |
86 | ||
87 | /** |