diff options
author | Alexander Schmidt <alexs@linux.vnet.ibm.com> | 2010-07-05 12:19:25 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2010-07-21 15:46:29 -0400 |
commit | e675b6db1245649f91bb1bfb10baef9af6d3f8e6 (patch) | |
tree | 83a471d78fb6b118aedd269f8eb5ac0b9b8b9336 /drivers | |
parent | 91fb0dd9cb71ab1a90ab1f48c34b935fdbca55b9 (diff) |
IB/ehca: Catch failing ioremap()
When ioremap() fails with a NULL pointer, catch the error and pass it
to the caller of create_qp() or create_cq() instead of trying to
dereference the NULL pointer later on.
Signed-off-by: Alexander Schmidt <alexs@linux.vnet.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/hw/ehca/hcp_if.c | 32 | ||||
-rw-r--r-- | drivers/infiniband/hw/ehca/hcp_phyp.c | 11 | ||||
-rw-r--r-- | drivers/infiniband/hw/ehca/hcp_phyp.h | 2 |
3 files changed, 34 insertions, 11 deletions
diff --git a/drivers/infiniband/hw/ehca/hcp_if.c b/drivers/infiniband/hw/ehca/hcp_if.c index 4d5dc3304d42..e6f9cdd94c7a 100644 --- a/drivers/infiniband/hw/ehca/hcp_if.c +++ b/drivers/infiniband/hw/ehca/hcp_if.c | |||
@@ -269,6 +269,7 @@ u64 hipz_h_alloc_resource_cq(const struct ipz_adapter_handle adapter_handle, | |||
269 | struct ehca_cq *cq, | 269 | struct ehca_cq *cq, |
270 | struct ehca_alloc_cq_parms *param) | 270 | struct ehca_alloc_cq_parms *param) |
271 | { | 271 | { |
272 | int rc; | ||
272 | u64 ret; | 273 | u64 ret; |
273 | unsigned long outs[PLPAR_HCALL9_BUFSIZE]; | 274 | unsigned long outs[PLPAR_HCALL9_BUFSIZE]; |
274 | 275 | ||
@@ -283,8 +284,19 @@ u64 hipz_h_alloc_resource_cq(const struct ipz_adapter_handle adapter_handle, | |||
283 | param->act_nr_of_entries = (u32)outs[3]; | 284 | param->act_nr_of_entries = (u32)outs[3]; |
284 | param->act_pages = (u32)outs[4]; | 285 | param->act_pages = (u32)outs[4]; |
285 | 286 | ||
286 | if (ret == H_SUCCESS) | 287 | if (ret == H_SUCCESS) { |
287 | hcp_galpas_ctor(&cq->galpas, 0, outs[5], outs[6]); | 288 | rc = hcp_galpas_ctor(&cq->galpas, 0, outs[5], outs[6]); |
289 | if (rc) { | ||
290 | ehca_gen_err("Could not establish HW access. rc=%d paddr=%#lx", | ||
291 | rc, outs[5]); | ||
292 | |||
293 | ehca_plpar_hcall_norets(H_FREE_RESOURCE, | ||
294 | adapter_handle.handle, /* r4 */ | ||
295 | cq->ipz_cq_handle.handle, /* r5 */ | ||
296 | 0, 0, 0, 0, 0); | ||
297 | ret = H_NO_MEM; | ||
298 | } | ||
299 | } | ||
288 | 300 | ||
289 | if (ret == H_NOT_ENOUGH_RESOURCES) | 301 | if (ret == H_NOT_ENOUGH_RESOURCES) |
290 | ehca_gen_err("Not enough resources. ret=%lli", ret); | 302 | ehca_gen_err("Not enough resources. ret=%lli", ret); |
@@ -295,6 +307,7 @@ u64 hipz_h_alloc_resource_cq(const struct ipz_adapter_handle adapter_handle, | |||
295 | u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle, | 307 | u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle, |
296 | struct ehca_alloc_qp_parms *parms, int is_user) | 308 | struct ehca_alloc_qp_parms *parms, int is_user) |
297 | { | 309 | { |
310 | int rc; | ||
298 | u64 ret; | 311 | u64 ret; |
299 | u64 allocate_controls, max_r10_reg, r11, r12; | 312 | u64 allocate_controls, max_r10_reg, r11, r12; |
300 | unsigned long outs[PLPAR_HCALL9_BUFSIZE]; | 313 | unsigned long outs[PLPAR_HCALL9_BUFSIZE]; |
@@ -358,8 +371,19 @@ u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle, | |||
358 | parms->rqueue.queue_size = | 371 | parms->rqueue.queue_size = |
359 | (u32)EHCA_BMASK_GET(H_ALL_RES_QP_RQUEUE_SIZE_PAGES, outs[4]); | 372 | (u32)EHCA_BMASK_GET(H_ALL_RES_QP_RQUEUE_SIZE_PAGES, outs[4]); |
360 | 373 | ||
361 | if (ret == H_SUCCESS) | 374 | if (ret == H_SUCCESS) { |
362 | hcp_galpas_ctor(&parms->galpas, is_user, outs[6], outs[6]); | 375 | rc = hcp_galpas_ctor(&parms->galpas, is_user, outs[6], outs[6]); |
376 | if (rc) { | ||
377 | ehca_gen_err("Could not establish HW access. rc=%d paddr=%#lx", | ||
378 | rc, outs[6]); | ||
379 | |||
380 | ehca_plpar_hcall_norets(H_FREE_RESOURCE, | ||
381 | adapter_handle.handle, /* r4 */ | ||
382 | parms->qp_handle.handle, /* r5 */ | ||
383 | 0, 0, 0, 0, 0); | ||
384 | ret = H_NO_MEM; | ||
385 | } | ||
386 | } | ||
363 | 387 | ||
364 | if (ret == H_NOT_ENOUGH_RESOURCES) | 388 | if (ret == H_NOT_ENOUGH_RESOURCES) |
365 | ehca_gen_err("Not enough resources. ret=%lli", ret); | 389 | ehca_gen_err("Not enough resources. ret=%lli", ret); |
diff --git a/drivers/infiniband/hw/ehca/hcp_phyp.c b/drivers/infiniband/hw/ehca/hcp_phyp.c index b3e0e72e8a73..077376ff3d28 100644 --- a/drivers/infiniband/hw/ehca/hcp_phyp.c +++ b/drivers/infiniband/hw/ehca/hcp_phyp.c | |||
@@ -42,10 +42,9 @@ | |||
42 | #include "ehca_classes.h" | 42 | #include "ehca_classes.h" |
43 | #include "hipz_hw.h" | 43 | #include "hipz_hw.h" |
44 | 44 | ||
45 | int hcall_map_page(u64 physaddr, u64 *mapaddr) | 45 | u64 hcall_map_page(u64 physaddr) |
46 | { | 46 | { |
47 | *mapaddr = (u64)(ioremap(physaddr, EHCA_PAGESIZE)); | 47 | return (u64)ioremap(physaddr, EHCA_PAGESIZE); |
48 | return 0; | ||
49 | } | 48 | } |
50 | 49 | ||
51 | int hcall_unmap_page(u64 mapaddr) | 50 | int hcall_unmap_page(u64 mapaddr) |
@@ -58,9 +57,9 @@ int hcp_galpas_ctor(struct h_galpas *galpas, int is_user, | |||
58 | u64 paddr_kernel, u64 paddr_user) | 57 | u64 paddr_kernel, u64 paddr_user) |
59 | { | 58 | { |
60 | if (!is_user) { | 59 | if (!is_user) { |
61 | int ret = hcall_map_page(paddr_kernel, &galpas->kernel.fw_handle); | 60 | galpas->kernel.fw_handle = hcall_map_page(paddr_kernel); |
62 | if (ret) | 61 | if (!galpas->kernel.fw_handle) |
63 | return ret; | 62 | return -ENOMEM; |
64 | } else | 63 | } else |
65 | galpas->kernel.fw_handle = 0; | 64 | galpas->kernel.fw_handle = 0; |
66 | 65 | ||
diff --git a/drivers/infiniband/hw/ehca/hcp_phyp.h b/drivers/infiniband/hw/ehca/hcp_phyp.h index 204227d5303a..d1b029910249 100644 --- a/drivers/infiniband/hw/ehca/hcp_phyp.h +++ b/drivers/infiniband/hw/ehca/hcp_phyp.h | |||
@@ -83,7 +83,7 @@ int hcp_galpas_ctor(struct h_galpas *galpas, int is_user, | |||
83 | 83 | ||
84 | int hcp_galpas_dtor(struct h_galpas *galpas); | 84 | int hcp_galpas_dtor(struct h_galpas *galpas); |
85 | 85 | ||
86 | int hcall_map_page(u64 physaddr, u64 * mapaddr); | 86 | u64 hcall_map_page(u64 physaddr); |
87 | 87 | ||
88 | int hcall_unmap_page(u64 mapaddr); | 88 | int hcall_unmap_page(u64 mapaddr); |
89 | 89 | ||