aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/acpi_pcihp.c
diff options
context:
space:
mode:
authorMUNEDA Takahiro <muneda.takahiro@jp.fujitsu.com>2006-03-16 19:18:39 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-23 17:35:17 -0500
commitb2e6e3ba7deb525f180df64f32f3fcb214538bea (patch)
tree116ae7111104708fce872b5d68dbd3fae7779174 /drivers/pci/hotplug/acpi_pcihp.c
parentdc6712d1261ee4585771724320d28580888818eb (diff)
[PATCH] acpiphp: fix acpi_path_name
I encountered the problem that the insmod of the acpiphp fails because of the mis-freeing of the memory. I tested this patch on my tiger4 box. Signed-off-by: MUNEDA Takahiro <muneda.takahiro@jp.fujitsu.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/hotplug/acpi_pcihp.c')
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c54
1 files changed, 19 insertions, 35 deletions
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index 0f7135317542..39af9c325f35 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -37,28 +37,6 @@
37#define METHOD_NAME__HPP "_HPP" 37#define METHOD_NAME__HPP "_HPP"
38#define METHOD_NAME_OSHP "OSHP" 38#define METHOD_NAME_OSHP "OSHP"
39 39
40/* acpi_path_name
41 *
42 * @handle - the acpi_handle of the object who's name you want.
43 *
44 * Caller must free buffer.
45 */
46u8 * acpi_path_name(acpi_handle handle)
47{
48 acpi_status status;
49 struct acpi_buffer ret_buf = {ACPI_ALLOCATE_BUFFER, NULL};
50 union acpi_object *obj;
51
52 status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &ret_buf);
53 if (ACPI_FAILURE(status)) {
54 return NULL;
55 }
56 obj = ret_buf.pointer;
57 return obj->string.pointer;
58}
59EXPORT_SYMBOL_GPL(acpi_path_name);
60
61
62 40
63static acpi_status 41static acpi_status
64acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) 42acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
@@ -66,10 +44,12 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
66 acpi_status status; 44 acpi_status status;
67 u8 nui[4]; 45 u8 nui[4];
68 struct acpi_buffer ret_buf = { 0, NULL}; 46 struct acpi_buffer ret_buf = { 0, NULL};
47 struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL };
69 union acpi_object *ext_obj, *package; 48 union acpi_object *ext_obj, *package;
70 u8 *path_name = acpi_path_name(handle);
71 int i, len = 0; 49 int i, len = 0;
72 50
51 acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
52
73 /* get _hpp */ 53 /* get _hpp */
74 status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf); 54 status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf);
75 switch (status) { 55 switch (status) {
@@ -77,8 +57,8 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
77 ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL); 57 ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL);
78 if (!ret_buf.pointer) { 58 if (!ret_buf.pointer) {
79 printk(KERN_ERR "%s:%s alloc for _HPP fail\n", 59 printk(KERN_ERR "%s:%s alloc for _HPP fail\n",
80 __FUNCTION__, path_name); 60 __FUNCTION__, (char *)string.pointer);
81 acpi_os_free(path_name); 61 acpi_os_free(string.pointer);
82 return AE_NO_MEMORY; 62 return AE_NO_MEMORY;
83 } 63 }
84 status = acpi_evaluate_object(handle, METHOD_NAME__HPP, 64 status = acpi_evaluate_object(handle, METHOD_NAME__HPP,
@@ -88,8 +68,8 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
88 default: 68 default:
89 if (ACPI_FAILURE(status)) { 69 if (ACPI_FAILURE(status)) {
90 pr_debug("%s:%s _HPP fail=0x%x\n", __FUNCTION__, 70 pr_debug("%s:%s _HPP fail=0x%x\n", __FUNCTION__,
91 path_name, status); 71 (char *)string.pointer, status);
92 acpi_os_free(path_name); 72 acpi_os_free(string.pointer);
93 return status; 73 return status;
94 } 74 }
95 } 75 }
@@ -97,7 +77,7 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
97 ext_obj = (union acpi_object *) ret_buf.pointer; 77 ext_obj = (union acpi_object *) ret_buf.pointer;
98 if (ext_obj->type != ACPI_TYPE_PACKAGE) { 78 if (ext_obj->type != ACPI_TYPE_PACKAGE) {
99 printk(KERN_ERR "%s:%s _HPP obj not a package\n", __FUNCTION__, 79 printk(KERN_ERR "%s:%s _HPP obj not a package\n", __FUNCTION__,
100 path_name); 80 (char *)string.pointer);
101 status = AE_ERROR; 81 status = AE_ERROR;
102 goto free_and_return; 82 goto free_and_return;
103 } 83 }
@@ -112,7 +92,7 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
112 break; 92 break;
113 default: 93 default:
114 printk(KERN_ERR "%s:%s _HPP obj type incorrect\n", 94 printk(KERN_ERR "%s:%s _HPP obj type incorrect\n",
115 __FUNCTION__, path_name); 95 __FUNCTION__, (char *)string.pointer);
116 status = AE_ERROR; 96 status = AE_ERROR;
117 goto free_and_return; 97 goto free_and_return;
118 } 98 }
@@ -129,8 +109,8 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
129 pr_debug(" _HPP: enable PERR =0x%x\n", hpp->enable_perr); 109 pr_debug(" _HPP: enable PERR =0x%x\n", hpp->enable_perr);
130 110
131free_and_return: 111free_and_return:
132 acpi_os_free(path_name); 112 acpi_os_free(string.pointer);
133 kfree(ret_buf.pointer); 113 acpi_os_free(ret_buf.pointer);
134 return status; 114 return status;
135} 115}
136 116
@@ -143,16 +123,20 @@ free_and_return:
143acpi_status acpi_run_oshp(acpi_handle handle) 123acpi_status acpi_run_oshp(acpi_handle handle)
144{ 124{
145 acpi_status status; 125 acpi_status status;
146 u8 *path_name = acpi_path_name(handle); 126 struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL };
127
128 acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
147 129
148 /* run OSHP */ 130 /* run OSHP */
149 status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL); 131 status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL);
150 if (ACPI_FAILURE(status)) 132 if (ACPI_FAILURE(status))
151 printk(KERN_ERR "%s:%s OSHP fails=0x%x\n", __FUNCTION__, 133 printk(KERN_ERR "%s:%s OSHP fails=0x%x\n", __FUNCTION__,
152 path_name, status); 134 (char *)string.pointer, status);
153 else 135 else
154 pr_debug("%s:%s OSHP passes\n", __FUNCTION__, path_name); 136 pr_debug("%s:%s OSHP passes\n", __FUNCTION__,
155 acpi_os_free(path_name); 137 (char *)string.pointer);
138
139 acpi_os_free(string.pointer);
156 return status; 140 return status;
157} 141}
158EXPORT_SYMBOL_GPL(acpi_run_oshp); 142EXPORT_SYMBOL_GPL(acpi_run_oshp);