diff options
-rw-r--r-- | drivers/infiniband/core/mad.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index 49c45feccd5b..5c54fc2350be 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c | |||
@@ -406,19 +406,15 @@ static int register_snoop_agent(struct ib_mad_qp_info *qp_info, | |||
406 | 406 | ||
407 | if (i == qp_info->snoop_table_size) { | 407 | if (i == qp_info->snoop_table_size) { |
408 | /* Grow table. */ | 408 | /* Grow table. */ |
409 | new_snoop_table = kmalloc(sizeof mad_snoop_priv * | 409 | new_snoop_table = krealloc(qp_info->snoop_table, |
410 | qp_info->snoop_table_size + 1, | 410 | sizeof mad_snoop_priv * |
411 | GFP_ATOMIC); | 411 | (qp_info->snoop_table_size + 1), |
412 | GFP_ATOMIC); | ||
412 | if (!new_snoop_table) { | 413 | if (!new_snoop_table) { |
413 | i = -ENOMEM; | 414 | i = -ENOMEM; |
414 | goto out; | 415 | goto out; |
415 | } | 416 | } |
416 | if (qp_info->snoop_table) { | 417 | |
417 | memcpy(new_snoop_table, qp_info->snoop_table, | ||
418 | sizeof mad_snoop_priv * | ||
419 | qp_info->snoop_table_size); | ||
420 | kfree(qp_info->snoop_table); | ||
421 | } | ||
422 | qp_info->snoop_table = new_snoop_table; | 418 | qp_info->snoop_table = new_snoop_table; |
423 | qp_info->snoop_table_size++; | 419 | qp_info->snoop_table_size++; |
424 | } | 420 | } |