public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Jiri Slaby <jirislaby@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH -v2 1/1] Misc: add sensable phantom driver
Date: Thu, 3 May 2007 10:36:07 -0700	[thread overview]
Message-ID: <20070503103607.e59773ae.akpm@linux-foundation.org> (raw)
In-Reply-To: <4639D821.9010308@gmail.com>

On Thu, 03 May 2007 14:40:01 +0200 Jiri Slaby <jirislaby@gmail.com> wrote:

> >> +static int phantom_release(struct inode *inode, struct file *file)
> >> +{
> >> +	struct phantom_device *dev = file->private_data;
> >> +
> >> +	if (mutex_lock_interruptible(&dev->open_lock))
> >> +		return -ERESTARTSYS;
> >> +
> >> +	dev->opened = 0;
> >> +	phantom_status(dev, dev->status & ~PHB_RUNNING);
> >> +
> >> +	mutex_unlock(&dev->open_lock);
> >> +
> >> +	return 0;
> >> +}
> > 
> > The mutex_lock_interruptible() is wrong, I think.  This function is called
> > when we do the final close().  If the signal _is_ taken then it's game
> > over: the device can no longer be opened.
> 
> Yes, starving at sys_close, I think so.
> 
> <fast searching in drivers/*>
> 
> Wouldn't this be a problem here too:
> drivers/media/dvb/cinergyT2/cinergyT2.c
> drivers/usb/misc/auerswald.c
> at least that the device won't be stopped or something like that?

Yes, those drivers appear to have the same problem.  I'll fix 'em.

> >> +/*
> >> + * Init and deinit driver
> >> + */
> >> +
> >> +static unsigned int __devinit phantom_get_free(void)
> >> +{
> >> +	unsigned int i;
> >> +
> >> +	for (i = 0; i < PHANTOM_MAX_MINORS; i++)
> >> +		if (phantom_devices[i] == 0)
> >> +			break;
> >> +
> >> +	return i;
> >> +}
> > 
> > This function assumes that the phantom_devices[] array will never have any
> > holes in it.  But if phantom_remove() is called out-of-order, it _will_
> > have holes.  Perhaps - I didn't look too hard.
> 
> I'm afraid I didn't get this. It goes through all phantom_devices and
> returns first free index. If a hole is present it will return "i" which
> corresponds to the hole, because phantom_devices[i] is 0. Note that it is
> unsigned char array.
> 

I guess I must have misread the code.

  reply	other threads:[~2007-05-03 17:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-02 15:56 [PATCH -v2 1/1] Misc: add sensable phantom driver Jiri Slaby
2007-05-03  6:49 ` Andrew Morton
2007-05-03 12:40   ` Jiri Slaby
2007-05-03 17:36     ` Andrew Morton [this message]
2007-05-03 14:41   ` Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070503103607.e59773ae.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox