From patchwork Sun Sep 16 02:58:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: axel lin X-Patchwork-Id: 1462631 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 627AD3FD40 for ; Sun, 16 Sep 2012 02:58:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750841Ab2IPC6e (ORCPT ); Sat, 15 Sep 2012 22:58:34 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:57206 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750740Ab2IPC6d (ORCPT ); Sat, 15 Sep 2012 22:58:33 -0400 Received: by pbbrr13 with SMTP id rr13so7438440pbb.19 for ; Sat, 15 Sep 2012 19:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:x-mailer :content-transfer-encoding:mime-version; bh=p1Ia5qeUbALexdUVMh6wXrZsIlAykE4nSGWCbadRCuQ=; b=LfuEBmBeiJPpm5DpSviIx++9IWqEuTcL1BX+a3n1c1Z7QuP7y09OPkwPZYb9zMZIEz DFojwuYpQDDsCUYmGEfzD2hraPIY14Un7DrXMqYIf8uq2S0j00WCGkvw0tGVrf/w45CP eWfuVhfybheQV5VGNWuqLM5NRYEhj7rCBHl07ELr3LXU3TS+4pT9IRHN5Wb2Fz0F/igx yj/ma/Hw646rwE1Bwf9q8AAiRqbzJg82g5a10BG3FarIatLuef+CIO7xVoq46KsPnABA yy99U8+fZmq10aK/M3tvrI8MNpA2GuWVmh5BCzOnHrySabH5DFlfvVQXapte5/xSv7Oa Y2ww== Received: by 10.68.222.40 with SMTP id qj8mr13138756pbc.139.1347764313124; Sat, 15 Sep 2012 19:58:33 -0700 (PDT) Received: from [218.173.173.79] (218-173-173-79.dynamic.hinet.net. [218.173.173.79]) by mx.google.com with ESMTPS id gh7sm4117223pbc.29.2012.09.15.19.58.30 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 15 Sep 2012 19:58:32 -0700 (PDT) Message-ID: <1347764305.3748.1.camel@phoenix> Subject: [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL From: Axel Lin To: Jiri Kosina Cc: srinivas pandruvada , Jonathan Cameron , linux-input@vger.kernel.org Date: Sun, 16 Sep 2012 10:58:25 +0800 X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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(-) 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);