Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933142AbbG1J6A (ORCPT ); Tue, 28 Jul 2015 05:58:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:58006 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932827AbbG1JxV (ORCPT ); Tue, 28 Jul 2015 05:53:21 -0400 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Srinivas Pandruvada , Jiri Kosina , Oliver Neukum , Jiri Slaby Subject: [PATCH 3.12 121/124] HID: hid-sensor-hub: fix sleeping function called from invalid context Date: Tue, 28 Jul 2015 11:53:02 +0200 Message-Id: <2aad6a5b0692236d322917b201778c2dcda3c083.1438076484.git.jslaby@suse.cz> X-Mailer: git-send-email 2.4.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2284 Lines: 57 From: Srinivas Pandruvada 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit f74346a04b79c9a5e50a2ee5e923b94195975d17 upstream. 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 Signed-off-by: Jiri Kosina Cc: Oliver Neukum Signed-off-by: Jiri Slaby --- 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 9e4cdca549c0..fe8618c5b5c1 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -255,13 +255,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: -- 2.4.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/