From: Johan Hovold <johan@kernel.org>
To: Octavian Purdila <octavian.purdila@intel.com>
Cc: gregkh@linuxfoundation.org, linus.walleij@linaro.org,
gnurou@gmail.com, wsa@the-dreams.de, sameo@linux.intel.com,
lee.jones@linaro.org, arnd@arndb.de, johan@kernel.org,
daniel.baluta@intel.com, laurentiu.palcu@intel.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org
Subject: Re: [PATCH v3 1/3] mfd: add support for Diolan DLN-2 devices
Date: Mon, 8 Sep 2014 14:08:20 +0200 [thread overview]
Message-ID: <20140908120820.GB9560@localhost> (raw)
In-Reply-To: <20140908113233.GA9560@localhost>
On Mon, Sep 08, 2014 at 01:32:33PM +0200, Johan Hovold wrote:
> On Fri, Sep 05, 2014 at 06:17:57PM +0300, Octavian Purdila wrote:
> > +static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
> > + void *obuf, int obuf_len, void *ibuf, int *ibuf_len)
> > +{
<snip>
> > + /* if we got here we know that the response header has been checked */
> > + rsp = rxc->urb->transfer_buffer;
> > + result = le16_to_cpu(rsp->result);
>
> Yes, but you haven't verified that rsp->hdr.size > 0, so you may still
> be reading stale data.
I meant that you haven't verified that the payload size > 1 (the header
size is included in rsp->hdr.size and result is two byte wide).
> > +
> > + if (result) {
> > + dev_dbg(dev, "%d received response with error %d\n",
> > + handle, result);
> > + ret = -EREMOTEIO;
> > + goto out_free_rx_slot;
> > + }
> > +
> > + if (!ibuf) {
> > + ret = 0;
> > + goto out_free_rx_slot;
> > + }
> > +
> > + if (*ibuf_len > rxc->urb->actual_length - sizeof(*rsp))
> > + *ibuf_len = rxc->urb->actual_length - sizeof(*rsp);
>
> And then you get an underflow here, although that doesn't seem to cause
> any troubles in this case.
Unless ibuf_len is -1...
> But why isn't ibuf_len unsigned?
>
> > +
> > + memcpy(ibuf, rsp + 1, *ibuf_len);
> > +
> > +out_free_rx_slot:
> > + free_rx_slot(dln2, rxs, rx_slot);
> > +
> > + return ret;
> > +}
Johan
next prev parent reply other threads:[~2014-09-08 12:10 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-05 15:17 [PATCH v3 0/3] mfd: add support for Diolan DLN-2 Octavian Purdila
[not found] ` <1409930279-1382-1-git-send-email-octavian.purdila-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-09-05 15:17 ` [PATCH v3 1/3] mfd: add support for Diolan DLN-2 devices Octavian Purdila
2014-09-08 11:32 ` Johan Hovold
2014-09-08 12:08 ` Johan Hovold [this message]
2014-09-08 13:20 ` Octavian Purdila
2014-09-08 13:24 ` Lee Jones
2014-09-08 13:45 ` Johan Hovold
2014-09-05 15:17 ` [PATCH v3 2/3] i2c: add support for Diolan DLN-2 USB-I2C adapter Octavian Purdila
2014-09-08 14:44 ` Johan Hovold
2014-09-08 15:57 ` Octavian Purdila
2014-09-08 16:30 ` Johan Hovold
2014-09-08 17:15 ` Octavian Purdila
[not found] ` <CAE1zotJomxwAJA3aXm9MHnHd5Pg9V=K7XaptOPWkArV0jio4DQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-08 17:28 ` Johan Hovold
2014-09-09 8:20 ` Lee Jones
2014-09-05 15:17 ` [PATCH v3 3/3] gpio: add support for the Diolan DLN-2 USB GPIO driver Octavian Purdila
2014-09-05 15:38 ` Johan Hovold
2014-09-05 16:04 ` Octavian Purdila
[not found] ` <CAE1zotK4QkA9PWW=uOmM-j=N=MNuBt1v3CgdA+GXctdFUZ3QKA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-09 9:36 ` Johan Hovold
2014-09-09 10:27 ` Octavian Purdila
2014-09-08 16:22 ` Johan Hovold
2014-09-08 16:44 ` Johan Hovold
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=20140908120820.GB9560@localhost \
--to=johan@kernel.org \
--cc=arnd@arndb.de \
--cc=daniel.baluta@intel.com \
--cc=gnurou@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=laurentiu.palcu@intel.com \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=octavian.purdila@intel.com \
--cc=sameo@linux.intel.com \
--cc=wsa@the-dreams.de \
/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;
as well as URLs for NNTP newsgroup(s).