From patchwork Mon Mar 24 23:25:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 3884601 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 E91CC9F2E8 for ; Mon, 24 Mar 2014 23:24:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 270B32022F for ; Mon, 24 Mar 2014 23:24:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 90AA92020A for ; Mon, 24 Mar 2014 23:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751132AbaCXXYa (ORCPT ); Mon, 24 Mar 2014 19:24:30 -0400 Received: from mga02.intel.com ([134.134.136.20]:25498 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbaCXXY3 (ORCPT ); Mon, 24 Mar 2014 19:24:29 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 24 Mar 2014 16:24:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,723,1389772800"; d="scan'208";a="479166793" Received: from spandruv-linux-hsb-test.jf.intel.com ([10.7.199.71]) by orsmga001.jf.intel.com with ESMTP; 24 Mar 2014 16:24:27 -0700 From: Srinivas Pandruvada To: jkosina@suse.cz Cc: linux-input@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH] HID: hid-sensor-hub: fix sleeping function called from invalid context Date: Mon, 24 Mar 2014 16:25:04 -0700 Message-Id: <1395703504-3945-1-git-send-email-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.4 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 Fix issue with the sleeping calling hid_hw_request under spinlock. When i2c is used as HID transport, this is calling kmalloc, which can sleep. So remove call to this function while under spinlock. [ 1067.021961] Call Trace: [ 1067.021970] [] dump_stack+0x4d/0x6f [ 1067.021976] [] __might_sleep+0xd2/0xf0 [ 1067.021981] [] __kmalloc+0xeb/0x200 [ 1067.021989] [] ? hid_alloc_report_buf+0x23/0x30 [ 1067.021993] [] hid_alloc_report_buf+0x23/0x30 [ 1067.021997] [] i2c_hid_request+0x57/0x110 [ 1067.022006] [] sensor_hub_input_attr_get_raw_value+0xbc/0x100 [hid_sensor_hub] Signed-off-by: Srinivas Pandruvada --- 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 9c22e14..9021c9c 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -260,13 +260,12 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev, spin_lock_irqsave(&data->lock, flags); data->pending.status = true; + spin_unlock_irqrestore(&data->lock, flags); report = sensor_hub_report(report_id, hsdev->hdev, HID_INPUT_REPORT); - if (!report) { - spin_unlock_irqrestore(&data->lock, flags); + if (!report) goto err_free; - } + hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT); - spin_unlock_irqrestore(&data->lock, flags); wait_for_completion_interruptible_timeout(&data->pending.ready, HZ*5); switch (data->pending.raw_size) { case 1: