aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
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
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')
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c54
-rw-r--r--drivers/pci/hotplug/pci_hotplug.h1
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c15
3 files changed, 27 insertions, 43 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);
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h
index e476ed033384..eb0d01d47236 100644
--- a/drivers/pci/hotplug/pci_hotplug.h
+++ b/drivers/pci/hotplug/pci_hotplug.h
@@ -190,7 +190,6 @@ struct hotplug_params {
190extern acpi_status acpi_run_oshp(acpi_handle handle); 190extern acpi_status acpi_run_oshp(acpi_handle handle);
191extern acpi_status acpi_get_hp_params_from_firmware(struct pci_dev *dev, 191extern acpi_status acpi_get_hp_params_from_firmware(struct pci_dev *dev,
192 struct hotplug_params *hpp); 192 struct hotplug_params *hpp);
193extern u8 * acpi_path_name(acpi_handle handle);
194int acpi_root_bridge(acpi_handle handle); 193int acpi_root_bridge(acpi_handle handle);
195#endif 194#endif
196#endif 195#endif
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 22dcd12e4c1c..6c14d9e46b2e 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -1246,7 +1246,7 @@ int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev)
1246 acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev)); 1246 acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev));
1247 struct pci_dev *pdev = dev; 1247 struct pci_dev *pdev = dev;
1248 struct pci_bus *parent; 1248 struct pci_bus *parent;
1249 u8 *path_name = NULL; 1249 struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL };
1250 1250
1251 /* 1251 /*
1252 * Per PCI firmware specification, we should run the ACPI _OSC 1252 * Per PCI firmware specification, we should run the ACPI _OSC
@@ -1278,16 +1278,17 @@ int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev)
1278 } 1278 }
1279 1279
1280 while (handle) { 1280 while (handle) {
1281 path_name = acpi_path_name(handle); 1281 acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
1282 dbg("Trying to get hotplug control for %s \n", path_name); 1282 dbg("Trying to get hotplug control for %s \n",
1283 (char *)string.pointer);
1283 status = pci_osc_control_set(handle, 1284 status = pci_osc_control_set(handle,
1284 OSC_PCI_EXPRESS_NATIVE_HP_CONTROL); 1285 OSC_PCI_EXPRESS_NATIVE_HP_CONTROL);
1285 if (status == AE_NOT_FOUND) 1286 if (status == AE_NOT_FOUND)
1286 status = acpi_run_oshp(handle); 1287 status = acpi_run_oshp(handle);
1287 if (ACPI_SUCCESS(status)) { 1288 if (ACPI_SUCCESS(status)) {
1288 dbg("Gained control for hotplug HW for pci %s (%s)\n", 1289 dbg("Gained control for hotplug HW for pci %s (%s)\n",
1289 pci_name(dev), path_name); 1290 pci_name(dev), (char *)string.pointer);
1290 acpi_os_free(path_name); 1291 acpi_os_free(string.pointer);
1291 return 0; 1292 return 0;
1292 } 1293 }
1293 if (acpi_root_bridge(handle)) 1294 if (acpi_root_bridge(handle))
@@ -1300,8 +1301,8 @@ int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev)
1300 1301
1301 err("Cannot get control of hotplug hardware for pci %s\n", 1302 err("Cannot get control of hotplug hardware for pci %s\n",
1302 pci_name(dev)); 1303 pci_name(dev));
1303 if (path_name) 1304
1304 acpi_os_free(path_name); 1305 acpi_os_free(string.pointer);
1305 return -1; 1306 return -1;
1306} 1307}
1307#endif 1308#endif