All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Oliver Neukum <oliver@neukum.org>
Cc: linux-usb@vger.kernel.org, Stefan Kopp <stefan_kopp@agilent.com>,
	Marcel Janssen <korgull@home.nl>,
	Felipe Balbi <me@felipebalbi.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: add USB test and measurement class driver
Date: Wed, 27 Aug 2008 09:08:54 -0700	[thread overview]
Message-ID: <20080827160854.GC19710@kroah.com> (raw)
In-Reply-To: <200808271013.07561.oliver@neukum.org>

On Wed, Aug 27, 2008 at 10:13:06AM +0200, Oliver Neukum wrote:
> Am Mittwoch 27 August 2008 02:05:01 schrieb Greg KH:
> > +static ssize_t usbtmc_read(struct file *filp, char __user *buf,
> > +                          size_t count, loff_t *f_pos)
> > +{
> > +       struct usbtmc_device_data *data;
> > +       struct device *dev;
> > +       unsigned long int n_characters;
> > +       u8 *buffer;
> > +       int actual;
> > +       int done;
> > +       int remaining;
> > +       int retval;
> > +       int this_part;
> > +
> > +       /* Get pointer to private data structure */
> > +       data = filp->private_data;
> > +       dev = &data->intf->dev;
> > +       buffer = data->buffer;
> > +
> > +       remaining = count;
> > +       done = 0;
> > +
> > +       while (remaining > 0) {
> > +               if (remaining > USBTMC_SIZE_IOBUFFER - 12 - 3)
> > +                       this_part = USBTMC_SIZE_IOBUFFER - 12 - 3;
> > +               else
> > +                       this_part = remaining;
> > +
> > +               /* Setup IO buffer for DEV_DEP_MSG_IN message
> > +                * Refer to class specs for details
> > +                */
> > +               buffer[0] = 2;
> > +               buffer[1] = data->bTag;
> > +               buffer[2] = ~(data->bTag);
> > +               buffer[3] = 0; /* Reserved */
> > +               buffer[4] = (this_part - 12 - 3) & 255;
> > +               buffer[5] = ((this_part - 12 - 3) >> 8) & 255;
> > +               buffer[6] = ((this_part - 12 - 3) >> 16) & 255;
> > +               buffer[7] = ((this_part - 12 - 3) >> 24) & 255;
> > +               buffer[8] = data->TermCharEnabled * 2;
> > +               /* Use term character? */
> > +               buffer[9] = data->TermChar;
> > +               buffer[10] = 0; /* Reserved */
> > +               buffer[11] = 0; /* Reserved */
> 
> This function will go bad if concurrent readers enter, yet it has no locking.

Now fixed with an i/o mutex.

thanks,

greg k-h

  reply	other threads:[~2008-08-27 16:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-27  0:05 [PATCH] USB: add USB test and measurement class driver Greg KH
2008-08-27  3:12 ` Greg KH
2008-08-27 16:36   ` Greg KH
2008-08-27  6:22 ` Marcel Janssen
2008-08-27 17:21   ` Greg KH
2008-08-27  8:08 ` Oliver Neukum
2008-08-27 15:40   ` Greg KH
2008-08-27 16:06   ` Alan Stern
2008-08-27 17:05     ` Oliver Neukum
2008-08-27  8:13 ` Oliver Neukum
2008-08-27 16:08   ` Greg KH [this message]
2008-08-27  8:56 ` Oliver Neukum
2008-08-27 15:28   ` Greg KH
2008-08-27 15:44     ` Oliver Neukum
2008-08-27 16:02       ` Greg KH
2008-08-27 16:11   ` Greg KH
2008-08-27 16:15   ` Greg KH

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=20080827160854.GC19710@kroah.com \
    --to=greg@kroah.com \
    --cc=korgull@home.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=me@felipebalbi.com \
    --cc=oliver@neukum.org \
    --cc=stefan_kopp@agilent.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.