From 7b0692f1c60a9551f8ad5fe706b79a23720a196c Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 14 Aug 2013 11:07:11 +0300 Subject: [PATCH] HID: hid-sensor-hub: change kmalloc + memcpy by kmemdup The patch substitutes kmemdup for kmalloc followed by memcpy. Signed-off-by: Andy Shevchenko Acked-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- drivers/hid/hid-sensor-hub.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 1877a2552483..e46e0134b0f9 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -430,11 +430,10 @@ static int sensor_hub_raw_event(struct hid_device *hdev, if (pdata->pending.status && pdata->pending.attr_usage_id == report->field[i]->usage->hid) { hid_dbg(hdev, "data was pending ...\n"); - pdata->pending.raw_data = kmalloc(sz, GFP_ATOMIC); - if (pdata->pending.raw_data) { - memcpy(pdata->pending.raw_data, ptr, sz); + pdata->pending.raw_data = kmemdup(ptr, sz, GFP_ATOMIC); + if (pdata->pending.raw_data) pdata->pending.raw_size = sz; - } else + else pdata->pending.raw_size = 0; complete(&pdata->pending.ready); }