From: Octavian Purdila <octavian.purdila@intel.com>
To: lee.jones@linaro.org
Cc: wsa@the-dreams.de, julia.lawall@lip6.fr,
dan.carpenter@oracle.com, johan@kernel.org,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 4/4] mfd: dln2: a couple endian fixes
Date: Tue, 18 Nov 2014 14:58:00 +0200 [thread overview]
Message-ID: <1416315480-2053-5-git-send-email-octavian.purdila@intel.com> (raw)
In-Reply-To: <1416315480-2053-1-git-send-email-octavian.purdila@intel.com>
From: Dan Carpenter <dan.carpenter@oracle.com>
Sparse catches a couple endian bugs.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Octavian Purdila <octavian.purdila@intel.com>
---
drivers/mfd/dln2.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
index df2fda9..559e6cc 100644
--- a/drivers/mfd/dln2.c
+++ b/drivers/mfd/dln2.c
@@ -436,6 +436,7 @@ static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
struct device *dev = &dln2->interface->dev;
const unsigned long timeout = DLN2_USB_TIMEOUT * HZ / 1000;
struct dln2_mod_rx_slots *rxs = &dln2->mod_rx_slots[handle];
+ int size;
spin_lock(&dln2->disconnect_lock);
if (!dln2->disconnect)
@@ -477,8 +478,9 @@ static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
/* if we got here we know that the response header has been checked */
rsp = rxc->urb->transfer_buffer;
+ size = le16_to_cpu(rsp->hdr.size);
- if (rsp->hdr.size < sizeof(*rsp)) {
+ if (size < sizeof(*rsp)) {
ret = -EPROTO;
goto out_free_rx_slot;
}
@@ -493,8 +495,8 @@ static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
if (!ibuf)
goto out_free_rx_slot;
- if (*ibuf_len > rsp->hdr.size - sizeof(*rsp))
- *ibuf_len = rsp->hdr.size - sizeof(*rsp);
+ if (*ibuf_len > size - sizeof(*rsp))
+ *ibuf_len = size - sizeof(*rsp);
memcpy(ibuf, rsp + 1, *ibuf_len);
--
1.9.1
next prev parent reply other threads:[~2014-11-18 12:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-18 12:57 [PATCH v2 0/4] dln2 fixes for ib-mfd-gpio-i2c-3.19 Octavian Purdila
2014-11-18 12:57 ` [PATCH v2 1/4] mfd: dln2: fix _dln2_transfer return code Octavian Purdila
2014-11-18 12:57 ` [PATCH v2 2/4] i2c: dln2: simplify return flow for dln2_i2c_enable Octavian Purdila
2014-11-18 12:57 ` [PATCH v2 3/4] mfd: dln2: add a limit check for invalid echo Octavian Purdila
2014-11-18 12:58 ` Octavian Purdila [this message]
[not found] ` <1416315480-2053-1-git-send-email-octavian.purdila-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-11-19 17:34 ` [GIT PULL] Immutable branch between MFD, GPIO and I2C (Second batch) Lee Jones
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=1416315480-2053-5-git-send-email-octavian.purdila@intel.com \
--to=octavian.purdila@intel.com \
--cc=dan.carpenter@oracle.com \
--cc=johan@kernel.org \
--cc=julia.lawall@lip6.fr \
--cc=lee.jones@linaro.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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).