* pull-request: can 2018-01-16
@ 2018-01-16 14:39 Marc Kleine-Budde
2018-01-16 14:39 ` [PATCH] can: peak: fix potential bug in packet fragmentation Marc Kleine-Budde
2018-01-17 21:10 ` pull-request: can 2018-01-16 David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2018-01-16 14:39 UTC (permalink / raw)
To: netdev; +Cc: davem, linux-can, kernel
Hello David,
this is a pull reqeust of a single patch for net/master:
This patch by Stephane Grosjean fixes a potential bug in the packet
fragmentation in the peak USB driver.
regards,
Marc
---
The following changes since commit 6311b7ce42e0c1d6d944bc099dc47e936c20cf11:
netlink: extack: avoid parenthesized string constant warning (2018-01-15 15:15:23 -0500)
are available in the Git repository at:
ssh://git@gitolite.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-4.15-20180116
for you to fetch changes up to d8a243af1a68395e07ac85384a2740d4134c67f4:
can: peak: fix potential bug in packet fragmentation (2018-01-16 15:33:15 +0100)
----------------------------------------------------------------
linux-can-fixes-for-4.15-20180116
----------------------------------------------------------------
Stephane Grosjean (1):
can: peak: fix potential bug in packet fragmentation
drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] can: peak: fix potential bug in packet fragmentation
2018-01-16 14:39 pull-request: can 2018-01-16 Marc Kleine-Budde
@ 2018-01-16 14:39 ` Marc Kleine-Budde
2018-01-17 21:10 ` pull-request: can 2018-01-16 David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2018-01-16 14:39 UTC (permalink / raw)
To: netdev
Cc: davem, linux-can, kernel, Stephane Grosjean, linux-stable,
Marc Kleine-Budde
From: Stephane Grosjean <s.grosjean@peak-system.com>
In some rare conditions when running one PEAK USB-FD interface over
a non high-speed USB controller, one useless USB fragment might be sent.
This patch fixes the way a USB command is fragmented when its length is
greater than 64 bytes and when the underlying USB controller is not a
high-speed one.
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
index 7ccdc3e30c98..53d6bb045e9e 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
@@ -184,7 +184,7 @@ static int pcan_usb_fd_send_cmd(struct peak_usb_device *dev, void *cmd_tail)
void *cmd_head = pcan_usb_fd_cmd_buffer(dev);
int err = 0;
u8 *packet_ptr;
- int i, n = 1, packet_len;
+ int packet_len;
ptrdiff_t cmd_len;
/* usb device unregistered? */
@@ -201,17 +201,13 @@ static int pcan_usb_fd_send_cmd(struct peak_usb_device *dev, void *cmd_tail)
}
packet_ptr = cmd_head;
+ packet_len = cmd_len;
/* firmware is not able to re-assemble 512 bytes buffer in full-speed */
- if ((dev->udev->speed != USB_SPEED_HIGH) &&
- (cmd_len > PCAN_UFD_LOSPD_PKT_SIZE)) {
- packet_len = PCAN_UFD_LOSPD_PKT_SIZE;
- n += cmd_len / packet_len;
- } else {
- packet_len = cmd_len;
- }
+ if (unlikely(dev->udev->speed != USB_SPEED_HIGH))
+ packet_len = min(packet_len, PCAN_UFD_LOSPD_PKT_SIZE);
- for (i = 0; i < n; i++) {
+ do {
err = usb_bulk_msg(dev->udev,
usb_sndbulkpipe(dev->udev,
PCAN_USBPRO_EP_CMDOUT),
@@ -224,7 +220,12 @@ static int pcan_usb_fd_send_cmd(struct peak_usb_device *dev, void *cmd_tail)
}
packet_ptr += packet_len;
- }
+ cmd_len -= packet_len;
+
+ if (cmd_len < PCAN_UFD_LOSPD_PKT_SIZE)
+ packet_len = cmd_len;
+
+ } while (packet_len > 0);
return err;
}
--
2.15.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: pull-request: can 2018-01-16
2018-01-16 14:39 pull-request: can 2018-01-16 Marc Kleine-Budde
2018-01-16 14:39 ` [PATCH] can: peak: fix potential bug in packet fragmentation Marc Kleine-Budde
@ 2018-01-17 21:10 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-01-17 21:10 UTC (permalink / raw)
To: mkl; +Cc: netdev, linux-can, kernel
From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Tue, 16 Jan 2018 15:39:10 +0100
> this is a pull reqeust of a single patch for net/master:
>
> This patch by Stephane Grosjean fixes a potential bug in the packet
> fragmentation in the peak USB driver.
Pulled, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-17 21:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-16 14:39 pull-request: can 2018-01-16 Marc Kleine-Budde
2018-01-16 14:39 ` [PATCH] can: peak: fix potential bug in packet fragmentation Marc Kleine-Budde
2018-01-17 21:10 ` pull-request: can 2018-01-16 David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.