From: "Wu, Bryan" <bryan.wu@analog.com>
To: dbrownell@users.sourceforge.net, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] USB gadget rndis: fix bug skb_push function may return an unaligned pointer bug
Date: Wed, 04 Apr 2007 14:28:33 +0800 [thread overview]
Message-ID: <1175668113.10608.41.camel@roc-desktop> (raw)
USB gadget rndis: skb_push function may return a pointer which is not
aligned as required by struct rndis_packet_msg_type.
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
---
drivers/usb/gadget/rndis.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 6ec8cf1..48335bb 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -1211,18 +1211,23 @@ int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed)
return 0;
}
+/* The pointer of header is not aligned, it will cause alignment exception.
+ * Use a temporary variable to avoid it.
+ */
void rndis_add_hdr (struct sk_buff *skb)
{
- struct rndis_packet_msg_type *header;
+ void *buf;
+ struct rndis_packet_msg_type *header;
if (!skb)
return;
- header = (void *) skb_push (skb, sizeof *header);
- memset (header, 0, sizeof *header);
- header->MessageType = __constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG);
- header->MessageLength = cpu_to_le32(skb->len);
- header->DataOffset = __constant_cpu_to_le32 (36);
- header->DataLength = cpu_to_le32(skb->len - sizeof *header);
+ buf = (void *) skb_push (skb, sizeof *header);
+ memset (buf, 0, sizeof *header);
+ header = (struct rndis_packet_msg_type *)buf;
+ put_unaligned(__constant_cpu_to_le32(REMOTE_NDIS_PACKET_MSG), &header->MessageType);
+ put_unaligned(cpu_to_le32(skb->len), &header->MessageLength);
+ put_unaligned(__constant_cpu_to_le32(36), &header->DataOffset);
+ put_unaligned(cpu_to_le32(skb->len - sizeof *header), &header->DataLength);
}
void rndis_free_response (int configNr, u8 *buf)
--
1.5.0.5
next reply other threads:[~2007-04-04 6:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-04 6:28 Wu, Bryan [this message]
2007-04-05 21:29 ` David Brownell
2007-04-06 2:25 ` Wu, Bryan
2007-04-06 4:02 ` [PATCH] USB gadget rndis: fix struct rndis_packet_msg_type unaligned bug Wu, Bryan
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=1175668113.10608.41.camel@roc-desktop \
--to=bryan.wu@analog.com \
--cc=akpm@linux-foundation.org \
--cc=dbrownell@users.sourceforge.net \
--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
Powered by JetHome