Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bed8bdfd authored by Eric Sesterhenn's avatar Eric Sesterhenn Committed by Roland Dreier
Browse files

IB: kmemdup() cleanup



Replace open coded kmemdup() to save some screen space, and allow
inlining/not inlining to be triggered by gcc.

Signed-off-by: default avatarEric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent a1a733f6
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -240,11 +240,10 @@ static void * cm_copy_private_data(const void *private_data,
	if (!private_data || !private_data_len)
	if (!private_data || !private_data_len)
		return NULL;
		return NULL;


	data = kmalloc(private_data_len, GFP_KERNEL);
	data = kmemdup(private_data, private_data_len, GFP_KERNEL);
	if (!data)
	if (!data)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);


	memcpy(data, private_data, private_data_len);
	return data;
	return data;
}
}


+1 −2
Original line number Original line Diff line number Diff line
@@ -140,10 +140,9 @@ static int copy_private_data(struct iwcm_id_private *cm_id_priv,
{
{
	void *p;
	void *p;


	p = kmalloc(event->private_data_len, GFP_ATOMIC);
	p = kmemdup(event->private_data, event->private_data_len, GFP_ATOMIC);
	if (!p)
	if (!p)
		return -ENOMEM;
		return -ENOMEM;
	memcpy(p, event->private_data, event->private_data_len);
	event->private_data = p;
	event->private_data = p;
	return 0;
	return 0;
}
}
+2 −4
Original line number Original line Diff line number Diff line
@@ -328,20 +328,18 @@ static int ib_ucm_event_process(struct ib_cm_event *evt,
	}
	}


	if (uvt->data_len) {
	if (uvt->data_len) {
		uvt->data = kmalloc(uvt->data_len, GFP_KERNEL);
		uvt->data = kmemdup(evt->private_data, uvt->data_len, GFP_KERNEL);
		if (!uvt->data)
		if (!uvt->data)
			goto err1;
			goto err1;


		memcpy(uvt->data, evt->private_data, uvt->data_len);
		uvt->resp.present |= IB_UCM_PRES_DATA;
		uvt->resp.present |= IB_UCM_PRES_DATA;
	}
	}


	if (uvt->info_len) {
	if (uvt->info_len) {
		uvt->info = kmalloc(uvt->info_len, GFP_KERNEL);
		uvt->info = kmemdup(info, uvt->info_len, GFP_KERNEL);
		if (!uvt->info)
		if (!uvt->info)
			goto err2;
			goto err2;


		memcpy(uvt->info, info, uvt->info_len);
		uvt->resp.present |= IB_UCM_PRES_INFO;
		uvt->resp.present |= IB_UCM_PRES_INFO;
	}
	}
	return 0;
	return 0;
+1 −2
Original line number Original line Diff line number Diff line
@@ -1100,11 +1100,10 @@ static struct ib_fmr *mthca_alloc_fmr(struct ib_pd *pd, int mr_access_flags,
	struct mthca_fmr *fmr;
	struct mthca_fmr *fmr;
	int err;
	int err;


	fmr = kmalloc(sizeof *fmr, GFP_KERNEL);
	fmr = kmemdup(fmr_attr, sizeof *fmr, GFP_KERNEL);
	if (!fmr)
	if (!fmr)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);


	memcpy(&fmr->attr, fmr_attr, sizeof *fmr_attr);
	err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num,
	err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num,
			     convert_access(mr_access_flags), fmr);
			     convert_access(mr_access_flags), fmr);