From patchwork Wed Aug 14 08:07:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 2844226 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 454EE9F239 for ; Wed, 14 Aug 2013 08:07:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 44D9C202EA for ; Wed, 14 Aug 2013 08:07:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2150D202D1 for ; Wed, 14 Aug 2013 08:07:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759432Ab3HNIHx (ORCPT ); Wed, 14 Aug 2013 04:07:53 -0400 Received: from mga09.intel.com ([134.134.136.24]:60005 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755153Ab3HNIHv (ORCPT ); Wed, 14 Aug 2013 04:07:51 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 14 Aug 2013 01:05:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,875,1367996400"; d="scan'208";a="362407092" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.173]) by orsmga001.jf.intel.com with ESMTP; 14 Aug 2013 01:07:24 -0700 Received: from andy by smile with local (Exim 4.80) (envelope-from ) id 1V9W6r-0005RO-9j; Wed, 14 Aug 2013 11:07:13 +0300 From: Andy Shevchenko To: Jiri Kosina , linux-input@vger.kernel.org, Srinivas Pandruvada Cc: Andy Shevchenko Subject: [PATCH 4/4] hid-sensor-hub: change kmalloc + memcpy by kmemdup Date: Wed, 14 Aug 2013 11:07:11 +0300 Message-Id: <1376467631-20857-4-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 1.8.4.rc2 In-Reply-To: <1376467631-20857-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1376467631-20857-1-git-send-email-andriy.shevchenko@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch substitutes kmemdup for kmalloc followed by memcpy. Signed-off-by: Andy Shevchenko --- 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); }