From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755647AbbISRj3 (ORCPT ); Sat, 19 Sep 2015 13:39:29 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:33235 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755108AbbISRjZ (ORCPT ); Sat, 19 Sep 2015 13:39:25 -0400 Date: Sat, 19 Sep 2015 10:39:20 -0700 From: Dmitry Torokhov To: cpaul@redhat.com Cc: David Herrmann , linux-kernel , "open list:HID CORE LAYER" , Linux API , Andrew Morton , Mauro Carvalho Chehab , Greg KH , Arnd Bergmann , Joe Perches , Jiri Slaby , Vishnu Patekar , Sebastian Ott , Benjamin Tissoires , Hans de Goede , linux-doc@vger.kernel.org Subject: Re: [PATCH v5] Input: Add userio module Message-ID: <20150919173920.GC7081@dtor-ws> References: <1442530810-28519-1-git-send-email-cpaul@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442530810-28519-1-git-send-email-cpaul@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stephen, On Thu, Sep 17, 2015 at 07:00:10PM -0400, cpaul@redhat.com wrote: > Responses > * Re: if (!userio) in userio_device_write(): it happens if we close the file > descriptor while the input driver is trying to talk to the device, since we > can't immediately bring down the driver. Removing the condition breaks the > driver ... > +/** > + * userio_device_write - Write data from serio to a userio device in userspace > + * @id: The serio port for the userio device > + * @val: The data to write to the device > + */ > +static int userio_device_write(struct serio *id, unsigned char val) > +{ > + struct userio_device *userio = id->port_data; > + > + if (!userio) > + return -1; 1. I do not see where we reset port data. 2. I do not see what prevents object to which you now have a pointer to from disappearing at any moment past your check. > + > + mutex_lock(&userio->lock); serio_write() must allow to be called from interrupt context, so you can't use mutex here. Thanks. -- Dmitry