isert-scst: Use kmalloc_array() instead of kmalloc() with multiply

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6636 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2015-11-09 20:09:14 +00:00
parent 5554a2a8b1
commit 9455a2b9dc
2 changed files with 4 additions and 4 deletions

View File

@@ -49,8 +49,8 @@ static int isert_buf_alloc_pg(struct ib_device *ib_dev,
struct page *page;
isert_buf->sg_cnt = DIV_ROUND_UP(size, PAGE_SIZE);
isert_buf->sg = kmalloc(sizeof(*isert_buf->sg) * isert_buf->sg_cnt,
GFP_KERNEL);
isert_buf->sg = kmalloc_array(isert_buf->sg_cnt, sizeof(*isert_buf->sg),
GFP_KERNEL);
if (unlikely(!isert_buf->sg)) {
pr_err("Failed to allocate buffer SG\n");
res = -ENOMEM;

View File

@@ -175,14 +175,14 @@ static int isert_alloc_for_rdma(struct isert_cmnd *pdu, int sge_cnt,
int i, ret = 0;
int wr_cnt;
sg_pool = kmalloc(sizeof(*sg_pool) * sge_cnt, GFP_KERNEL);
sg_pool = kmalloc_array(sge_cnt, sizeof(*sg_pool), GFP_KERNEL);
if (unlikely(sg_pool == NULL)) {
ret = -ENOMEM;
goto out;
}
wr_cnt = DIV_ROUND_UP(sge_cnt, isert_conn->max_sge);
wr = kmalloc(sizeof(*wr) * wr_cnt, GFP_KERNEL);
wr = kmalloc_array(wr_cnt, sizeof(*wr), GFP_KERNEL);
if (unlikely(wr == NULL)) {
ret = -ENOMEM;
goto out_free_sg_pool;