diff mbox

[4/4] hid-sensor-hub: change kmalloc + memcpy by kmemdup

Message ID 1376467631-20857-4-git-send-email-andriy.shevchenko@linux.intel.com
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Andy Shevchenko Aug. 14, 2013, 8:07 a.m. UTC
The patch substitutes kmemdup for kmalloc followed by memcpy.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hid/hid-sensor-hub.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Srinivas Pandruvada Aug. 19, 2013, 3:32 p.m. UTC | #1
On 08/14/2013 01:07 AM, Andy Shevchenko wrote:
> The patch substitutes kmemdup for kmalloc followed by memcpy.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   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 4cb19df..0794e9f 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);
>   		}
Agreed.

Thanks,
Srinivas
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 4cb19df..0794e9f 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);
 		}