Commit 7df109d9 authored by Hoang-Nam Nguyen's avatar Hoang-Nam Nguyen Committed by Roland Dreier

IB/ehca: handle negative return value from ibmebus_request_irq() properly

ehca_create_eq() was assigning a signed return value to an unsiged
local variable and then checking if the variable was < 0, which meant
that errors were always ignored.  Fix this by using one variable for
signed integer return values and another for u64 hcall return values.

Bug originally found by Roel Kluin <12o3l@tiscali.nl>.
Signed-off-by: default avatarHoang-Nam Nguyen <hnguyen@de.ibm.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent f8b0dfd1
...@@ -54,7 +54,8 @@ int ehca_create_eq(struct ehca_shca *shca, ...@@ -54,7 +54,8 @@ int ehca_create_eq(struct ehca_shca *shca,
struct ehca_eq *eq, struct ehca_eq *eq,
const enum ehca_eq_type type, const u32 length) const enum ehca_eq_type type, const u32 length)
{ {
u64 ret; int ret;
u64 h_ret;
u32 nr_pages; u32 nr_pages;
u32 i; u32 i;
void *vpage; void *vpage;
...@@ -73,7 +74,7 @@ int ehca_create_eq(struct ehca_shca *shca, ...@@ -73,7 +74,7 @@ int ehca_create_eq(struct ehca_shca *shca,
return -EINVAL; return -EINVAL;
} }
ret = hipz_h_alloc_resource_eq(shca->ipz_hca_handle, h_ret = hipz_h_alloc_resource_eq(shca->ipz_hca_handle,
&eq->pf, &eq->pf,
type, type,
length, length,
...@@ -81,7 +82,7 @@ int ehca_create_eq(struct ehca_shca *shca, ...@@ -81,7 +82,7 @@ int ehca_create_eq(struct ehca_shca *shca,
&eq->length, &eq->length,
&nr_pages, &eq->ist); &nr_pages, &eq->ist);
if (ret != H_SUCCESS) { if (h_ret != H_SUCCESS) {
ehca_err(ib_dev, "Can't allocate EQ/NEQ. eq=%p", eq); ehca_err(ib_dev, "Can't allocate EQ/NEQ. eq=%p", eq);
return -EINVAL; return -EINVAL;
} }
...@@ -97,13 +98,11 @@ int ehca_create_eq(struct ehca_shca *shca, ...@@ -97,13 +98,11 @@ int ehca_create_eq(struct ehca_shca *shca,
u64 rpage; u64 rpage;
vpage = ipz_qpageit_get_inc(&eq->ipz_queue); vpage = ipz_qpageit_get_inc(&eq->ipz_queue);
if (!vpage) { if (!vpage)
ret = H_RESOURCE;
goto create_eq_exit2; goto create_eq_exit2;
}
rpage = virt_to_abs(vpage); rpage = virt_to_abs(vpage);
ret = hipz_h_register_rpage_eq(shca->ipz_hca_handle, h_ret = hipz_h_register_rpage_eq(shca->ipz_hca_handle,
eq->ipz_eq_handle, eq->ipz_eq_handle,
&eq->pf, &eq->pf,
0, 0, rpage, 1); 0, 0, rpage, 1);
...@@ -111,10 +110,10 @@ int ehca_create_eq(struct ehca_shca *shca, ...@@ -111,10 +110,10 @@ int ehca_create_eq(struct ehca_shca *shca,
if (i == (nr_pages - 1)) { if (i == (nr_pages - 1)) {
/* last page */ /* last page */
vpage = ipz_qpageit_get_inc(&eq->ipz_queue); vpage = ipz_qpageit_get_inc(&eq->ipz_queue);
if (ret != H_SUCCESS || vpage) if (h_ret != H_SUCCESS || vpage)
goto create_eq_exit2; goto create_eq_exit2;
} else { } else {
if (ret != H_PAGE_REGISTERED || !vpage) if (h_ret != H_PAGE_REGISTERED || !vpage)
goto create_eq_exit2; goto create_eq_exit2;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment