From patchwork Thu Dec 11 14:03:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 5476071 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 01F0B9F1D4 for ; Thu, 11 Dec 2014 14:03:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 23244200E0 for ; Thu, 11 Dec 2014 14:03:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C00E0201B9 for ; Thu, 11 Dec 2014 14:03:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933097AbaLKOD1 (ORCPT ); Thu, 11 Dec 2014 09:03:27 -0500 Received: from mga11.intel.com ([192.55.52.93]:35304 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932802AbaLKOD0 (ORCPT ); Thu, 11 Dec 2014 09:03:26 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 11 Dec 2014 06:03:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,557,1413270000"; d="scan'208";a="636133849" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.95]) by fmsmga001.fm.intel.com with SMTP; 11 Dec 2014 06:03:08 -0800 Received: by lahna (sSMTP sendmail emulation); Thu, 11 Dec 2014 16:03:07 +0200 Date: Thu, 11 Dec 2014 16:03:07 +0200 From: Mika Westerberg To: Gabriele Mazzotta Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, benjamin.tissoires@redhat.com, aduggan@synaptics.com, jkosina@suse.cz Subject: Re: NULL pointer dereference in i2c-hid Message-ID: <20141211140307.GE1300@lahna.fi.intel.com> References: <31518562.V5Oyo0POsI@xps13> <20141211085801.GR1300@lahna.fi.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20141211085801.GR1300@lahna.fi.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 On Thu, Dec 11, 2014 at 10:58:01AM +0200, Mika Westerberg wrote: > On Wed, Dec 10, 2014 at 06:04:51PM +0100, Gabriele Mazzotta wrote: > > my laptop uses a touchpad that needs hid-rmi along with i2c-hid to work. > > i2c-hid and hid-rmi can be loaded and unloaded independelty from each > > other, however since 34f439e4afcd ("HID: i2c-hid: add runtime PM support") > > if I unload hid-rmi and after it I also unload i2c-hid, I get a NULL > > pointer dereference. > > I'll look into this. > > I can reproduce this easily with i2c-hid + hid-multitouch following your > directions. Can you try the below patch? I think we shouldn't free buffers yet in ->stop() because we need the command buffer sending power commands to the device. Also it seems that ->start() re-allocates buffers anyway if maximum size increases. It shouldn't even leak memory as we release buffers at ->remove() anyway. --- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 62cec01937ea..68a8c938feea 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -705,12 +705,7 @@ static int i2c_hid_start(struct hid_device *hid) static void i2c_hid_stop(struct hid_device *hid) { - struct i2c_client *client = hid->driver_data; - struct i2c_hid *ihid = i2c_get_clientdata(client); - hid->claimed = 0; - - i2c_hid_free_buffers(ihid); } static int i2c_hid_open(struct hid_device *hid)