From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: linux1394-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, PaX Team <pageexec@freemail.hu>
Subject: [PATCH 6/6] firewire: sbp2: fix status reception
Date: Sun, 6 Sep 2009 18:51:27 +0200 (CEST) [thread overview]
Message-ID: <tkrat.2c7e855a0f668383@s5r6.in-berlin.de> (raw)
In-Reply-To: <tkrat.85bb80d9295444c1@s5r6.in-berlin.de>
Per SBP-2 clause 5.3, a target shall store 8...32 bytes of status
information. Trailing zeros after the first 8 bytes don't need to be
stored, they are implicit. Fix the status write handler to clear all
unwritten status data.
While we are at it, remove the trivial fw_memcpy_from_be32() helper.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
drivers/firewire/sbp2.c | 13 +++++++------
include/linux/firewire.h | 10 ----------
2 files changed, 7 insertions(+), 16 deletions(-)
Index: linux-2.6.31-rc9/drivers/firewire/sbp2.c
===================================================================
--- linux-2.6.31-rc9.orig/drivers/firewire/sbp2.c
+++ linux-2.6.31-rc9/drivers/firewire/sbp2.c
@@ -425,19 +425,20 @@ static void sbp2_status_write(struct fw_
struct sbp2_logical_unit *lu = callback_data;
struct sbp2_orb *orb;
struct sbp2_status status;
- size_t header_size;
unsigned long flags;
if (tcode != TCODE_WRITE_BLOCK_REQUEST ||
- length == 0 || length > sizeof(status)) {
+ length < 8 || length > sizeof(status)) {
fw_send_response(card, request, RCODE_TYPE_ERROR);
return;
}
- header_size = min(length, 2 * sizeof(u32));
- fw_memcpy_from_be32(&status, payload, header_size);
- if (length > header_size)
- memcpy(status.data, payload + 8, length - header_size);
+ status.status = be32_to_cpup(payload);
+ status.orb_low = be32_to_cpup(payload + 4);
+ memset(status.data, 0, sizeof(status.data));
+ if (length > 8)
+ memcpy(status.data, payload + 8, length - 8);
+
if (STATUS_GET_SOURCE(status) == 2 || STATUS_GET_SOURCE(status) == 3) {
fw_notify("non-orb related status write, not handled\n");
fw_send_response(card, request, RCODE_COMPLETE);
Index: linux-2.6.31-rc9/include/linux/firewire.h
===================================================================
--- linux-2.6.31-rc9.orig/include/linux/firewire.h
+++ linux-2.6.31-rc9/include/linux/firewire.h
@@ -20,16 +20,6 @@
#define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args)
#define fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
-static inline void fw_memcpy_from_be32(void *_dst, void *_src, size_t size)
-{
- u32 *dst = _dst;
- __be32 *src = _src;
- int i;
-
- for (i = 0; i < size / 4; i++)
- dst[i] = be32_to_cpu(src[i]);
-}
-
#define CSR_REGISTER_BASE 0xfffff0000000ULL
/* register offsets are relative to CSR_REGISTER_BASE */
--
Stefan Richter
-=====-==--= =--= --==-
http://arcgraph.de/sr/
prev parent reply other threads:[~2009-09-06 16:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-06 16:46 [PATCH 0/6] firewire: minor fixes and cleanups Stefan Richter
2009-09-06 16:48 ` [PATCH 1/6] firewire: core: reduce stack usage in bus reset tasklet Stefan Richter
2009-09-07 19:02 ` pageexec
2009-09-07 19:15 ` Stefan Richter
2009-09-07 21:24 ` Stefan Richter
2009-09-06 16:49 ` [PATCH 2/6] firewire: ohci: fix Self ID Count register mask (safeguard against buffer overflow) Stefan Richter
2009-09-07 18:56 ` pageexec
2009-09-07 19:28 ` Stefan Richter
2009-09-06 16:49 ` [PATCH 3/6] firewire: core: header file cleanup Stefan Richter
2009-09-06 16:50 ` [PATCH 4/6] firewire: core: fix race with parallel PCI device probe Stefan Richter
2009-09-06 16:50 ` [PATCH 5/6] firewire: reduce some memsets Stefan Richter
2009-09-06 16:51 ` Stefan Richter [this message]
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=tkrat.2c7e855a0f668383@s5r6.in-berlin.de \
--to=stefanr@s5r6.in-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=pageexec@freemail.hu \
/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
all inboxes | Powered by JetHome®