* [PATCH] USB gadget rndis: fix bug skb_push function may return an unaligned pointer bug
@ 2007-04-04 6:28 Wu, Bryan
2007-04-05 21:29 ` David Brownell
0 siblings, 1 reply; 4+ messages in thread
From: Wu, Bryan @ 2007-04-04 6:28 UTC (permalink / raw)
To: dbrownell, linux-kernel, Andrew Morton
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] USB gadget rndis: fix bug skb_push function may return an unaligned pointer bug
2007-04-04 6:28 [PATCH] USB gadget rndis: fix bug skb_push function may return an unaligned pointer bug Wu, Bryan
@ 2007-04-05 21:29 ` David Brownell
2007-04-06 2:25 ` Wu, Bryan
0 siblings, 1 reply; 4+ messages in thread
From: David Brownell @ 2007-04-05 21:29 UTC (permalink / raw)
To: bryan.wu; +Cc: linux-kernel, Andrew Morton
On Tuesday 03 April 2007 11:28 pm, Wu, Bryan wrote:
> USB gadget rndis: skb_push function may return a pointer which is not
> aligned as required by struct rndis_packet_msg_type.
Can you instead try to update the declaration of that struct
so that it's "__attribute__((packed))"? That's less invasive,
and will address similar issues elsewhere ...
- Dave
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] USB gadget rndis: fix bug skb_push function may return an unaligned pointer bug
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
0 siblings, 1 reply; 4+ messages in thread
From: Wu, Bryan @ 2007-04-06 2:25 UTC (permalink / raw)
To: David Brownell, jie.zhang, roy.huang
Cc: bryan.wu, linux-kernel, Andrew Morton
On Thu, 2007-04-05 at 14:29 -0700, David Brownell wrote:
> On Tuesday 03 April 2007 11:28 pm, Wu, Bryan wrote:
> > USB gadget rndis: skb_push function may return a pointer which is not
> > aligned as required by struct rndis_packet_msg_type.
>
> Can you instead try to update the declaration of that struct
> so that it's "__attribute__((packed))"? That's less invasive,
> and will address similar issues elsewhere ...
>
> - Dave
OK, Jie and Roy will try to use this __attribute__ method and test it on
blackfin platform. Sorry for missing their "Signed-off-by". I will
resend a patch later for review.
Thanks
-Bryan
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] USB gadget rndis: fix struct rndis_packet_msg_type unaligned bug
2007-04-06 2:25 ` Wu, Bryan
@ 2007-04-06 4:02 ` Wu, Bryan
0 siblings, 0 replies; 4+ messages in thread
From: Wu, Bryan @ 2007-04-06 4:02 UTC (permalink / raw)
To: David Brownell, jie.zhang, roy.huang, linux-kernel,
Andrew Morton, bryan.wu
[PATCH] usb gadget rndis:
skb_push function may return a pointer which is not aligned as required
by struct rndis_packet_msg_type. Using attribute trick to fix this bug.
Signed-off-by: Roy Huang <roy.huang@analog.com>
Signed-off-by: Jie Zhang <jie.zhang@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
---
drivers/usb/gadget/rndis.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/gadget/rndis.h b/drivers/usb/gadget/rndis.h
index 4c3c725..397b149 100644
--- a/drivers/usb/gadget/rndis.h
+++ b/drivers/usb/gadget/rndis.h
@@ -195,7 +195,7 @@ struct rndis_packet_msg_type
__le32 PerPacketInfoLength;
__le32 VcHandle;
__le32 Reserved;
-};
+} __attribute__ ((packed));
struct rndis_config_parameter
{
--
1.5.0.5
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-04-06 4:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-04 6:28 [PATCH] USB gadget rndis: fix bug skb_push function may return an unaligned pointer bug Wu, Bryan
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
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