From patchwork Sun Sep 16 03:30:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pandruvada, Srinivas" X-Patchwork-Id: 1462651 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6B34040AF9 for ; Sun, 16 Sep 2012 03:31:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751412Ab2IPDbU (ORCPT ); Sat, 15 Sep 2012 23:31:20 -0400 Received: from mga09.intel.com ([134.134.136.24]:41208 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751635Ab2IPDbA (ORCPT ); Sat, 15 Sep 2012 23:31:00 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 15 Sep 2012 20:30:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,428,1344236400"; d="scan'208";a="205079954" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by orsmga002.jf.intel.com with ESMTP; 15 Sep 2012 20:30:43 -0700 Received: from orsmsx108.amr.corp.intel.com ([169.254.9.202]) by ORSMSX106.amr.corp.intel.com ([169.254.5.60]) with mapi id 14.01.0355.002; Sat, 15 Sep 2012 20:30:43 -0700 From: "Pandruvada, Srinivas" To: Axel Lin , Jiri Kosina CC: Jonathan Cameron , "linux-input@vger.kernel.org" Subject: RE: [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL Thread-Topic: [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL Thread-Index: AQHNk7coQMh3eMZow0SKzAP7Ngv90JeMT5GA Date: Sun, 16 Sep 2012 03:30:42 +0000 Message-ID: <4FA419E87744DF4DAECD5BCE1214B7A919D526B6@ORSMSX108.amr.corp.intel.com> References: <1347764305.3748.1.camel@phoenix> In-Reply-To: <1347764305.3748.1.camel@phoenix> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org There is already a patch submitted to change to GFP_ATOMIC, which address this. -----Original Message----- From: Axel Lin [mailto:axel.lin@gmail.com] Sent: Saturday, September 15, 2012 7:58 PM To: Jiri Kosina Cc: Pandruvada, Srinivas; Jonathan Cameron; linux-input@vger.kernel.org Subject: [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL kzalloc might cause sleep, so don't hold spin lock while calling kzalloc with GFP_KERNEL. Signed-off-by: Axel Lin --- drivers/hid/hid-sensor-hub.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 1.7.9.5 diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 4ac759c..162bf6a 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -173,14 +173,17 @@ int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev, spin_unlock(&pdata->dyn_callback_lock); return -EINVAL; } + spin_unlock(&pdata->dyn_callback_lock); + callback = kzalloc(sizeof(*callback), GFP_KERNEL); - if (!callback) { - spin_unlock(&pdata->dyn_callback_lock); + if (!callback) return -ENOMEM; - } + callback->usage_callback = usage_callback; callback->usage_id = usage_id; callback->priv = NULL; + + spin_lock(&pdata->dyn_callback_lock); list_add_tail(&callback->list, &pdata->dyn_callback_list); spin_unlock(&pdata->dyn_callback_lock);