# Re: \[PATCH v7\] Input: Add userio module

- From: Dmitry Torokhov \<dmitry.torokhov@gmail.com\>
- Date: 2015-10-24 22:27:55 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2015/10/4606226
- Thread: https://ratatoskr.run/linux-api/2015/09/4578274/t.md

```text
On Thu, Oct 08, 2015 at 07:20:59PM +0200, David Herrmann wrote:
> On Mon, Oct 5, 2015 at 5:55 PM,  [ref] wrote:
> > +static int userio_char_release(struct inode *inode, struct file *file)
> > +{
> > +       struct userio_device *userio = file->private_data;
> > +
> > +       /* Don't free the serio port here, serio_unregister_port() does
> > +        * this for us */
> > +       if (userio->running)
> > +               serio_unregister_port(userio->serio);
> > +       else
> > +               kfree(userio->serio);
> > +
> > +       kfree(userio);
> 
> I'm not very familiar with the serio-subsystem, but is there a
> guarantee that .write() will not be called once unregistered? I can
> see that it's not scheduled by userio anymore, but maybe there's an
> async path that can trigger .write() callbacks. Dunno.. I'll leave
> that to Dmitry.

I think this is OK. When port is unregistered we the driver will be
disconnected from it, and is not supposed to call serio_write() anymore.
In fact, it should not access port after calling serio_close(). If it
keeps the pointer and uses it is a bug in the other driver; we can't
really do much about it.

Thanks.

-- 
Dmitry
```
