usb: gadget: Use unaligned access for wMaxPacketSize
Use get_unaligned() while fetching wMaxPacketSize to avoid voilating any alignment rules. Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Piotr Wilczek <p.wilczek@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Lukasz Dalek <luk0104@gmail.com> Cc: Marek Vasut <marex@denx.de>
This commit is contained in:
parent
f903a20d1f
commit
f6664ba4bc
|
@ -2261,7 +2261,8 @@ reset:
|
||||||
if (rc)
|
if (rc)
|
||||||
goto reset;
|
goto reset;
|
||||||
fsg->bulk_out_enabled = 1;
|
fsg->bulk_out_enabled = 1;
|
||||||
common->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize);
|
common->bulk_out_maxpacket =
|
||||||
|
le16_to_cpu(get_unaligned(&d->wMaxPacketSize));
|
||||||
clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
|
clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
|
||||||
|
|
||||||
/* Allocate the requests */
|
/* Allocate the requests */
|
||||||
|
|
|
@ -314,7 +314,8 @@ static int pxa25x_ep_enable(struct usb_ep *_ep,
|
||||||
if (!_ep || !desc || ep->desc || _ep->name == ep0name
|
if (!_ep || !desc || ep->desc || _ep->name == ep0name
|
||||||
|| desc->bDescriptorType != USB_DT_ENDPOINT
|
|| desc->bDescriptorType != USB_DT_ENDPOINT
|
||||||
|| ep->bEndpointAddress != desc->bEndpointAddress
|
|| ep->bEndpointAddress != desc->bEndpointAddress
|
||||||
|| ep->fifo_size < le16_to_cpu(desc->wMaxPacketSize)) {
|
|| ep->fifo_size <
|
||||||
|
le16_to_cpu(get_unaligned(&desc->wMaxPacketSize))) {
|
||||||
printf("%s, bad ep or descriptor\n", __func__);
|
printf("%s, bad ep or descriptor\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -329,9 +330,9 @@ static int pxa25x_ep_enable(struct usb_ep *_ep,
|
||||||
|
|
||||||
/* hardware _could_ do smaller, but driver doesn't */
|
/* hardware _could_ do smaller, but driver doesn't */
|
||||||
if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
|
if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
|
||||||
&& le16_to_cpu(desc->wMaxPacketSize)
|
&& le16_to_cpu(get_unaligned(&desc->wMaxPacketSize))
|
||||||
!= BULK_FIFO_SIZE)
|
!= BULK_FIFO_SIZE)
|
||||||
|| !desc->wMaxPacketSize) {
|
|| !get_unaligned(&desc->wMaxPacketSize)) {
|
||||||
printf("%s, bad %s maxpacket\n", __func__, _ep->name);
|
printf("%s, bad %s maxpacket\n", __func__, _ep->name);
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +346,7 @@ static int pxa25x_ep_enable(struct usb_ep *_ep,
|
||||||
ep->desc = desc;
|
ep->desc = desc;
|
||||||
ep->stopped = 0;
|
ep->stopped = 0;
|
||||||
ep->pio_irqs = 0;
|
ep->pio_irqs = 0;
|
||||||
ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
|
ep->ep.maxpacket = le16_to_cpu(get_unaligned(&desc->wMaxPacketSize));
|
||||||
|
|
||||||
/* flush fifo (mostly for OUT buffers) */
|
/* flush fifo (mostly for OUT buffers) */
|
||||||
pxa25x_ep_fifo_flush(_ep);
|
pxa25x_ep_fifo_flush(_ep);
|
||||||
|
@ -485,7 +486,7 @@ write_fifo(struct pxa25x_ep *ep, struct pxa25x_request *req)
|
||||||
{
|
{
|
||||||
unsigned max;
|
unsigned max;
|
||||||
|
|
||||||
max = le16_to_cpu(ep->desc->wMaxPacketSize);
|
max = le16_to_cpu(get_unaligned(&ep->desc->wMaxPacketSize));
|
||||||
do {
|
do {
|
||||||
unsigned count;
|
unsigned count;
|
||||||
int is_last, is_short;
|
int is_last, is_short;
|
||||||
|
@ -766,7 +767,7 @@ pxa25x_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
|
||||||
*/
|
*/
|
||||||
if (unlikely(ep->bmAttributes == USB_ENDPOINT_XFER_ISOC
|
if (unlikely(ep->bmAttributes == USB_ENDPOINT_XFER_ISOC
|
||||||
&& req->req.length >
|
&& req->req.length >
|
||||||
le16_to_cpu(ep->desc->wMaxPacketSize)))
|
le16_to_cpu(get_unaligned(&ep->desc->wMaxPacketSize))))
|
||||||
return -EMSGSIZE;
|
return -EMSGSIZE;
|
||||||
|
|
||||||
debug_cond(NOISY, "%s queue req %p, len %d buf %p\n",
|
debug_cond(NOISY, "%s queue req %p, len %d buf %p\n",
|
||||||
|
|
Loading…
Reference in New Issue