Skip to content

Commit

Permalink
Merge tag 'linux-can-fixes-for-4.5-20160221' of git://git.kernel.org/…
Browse files Browse the repository at this point in the history
…pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says:

====================
pull-request: can 2016-02-21

this is a pull reqeust of one patch for net/master.

The patch is by Gerhard Uttenthaler and fixes a potential tx overflow in the
ems_usb driver.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Feb 22, 2016
2 parents dd78dac + 90cfde4 commit d856626
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions drivers/net/can/usb/ems_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ MODULE_LICENSE("GPL v2");
*/
#define EMS_USB_ARM7_CLOCK 8000000

#define CPC_TX_QUEUE_TRIGGER_LOW 25
#define CPC_TX_QUEUE_TRIGGER_HIGH 35

/*
* CAN-Message representation in a CPC_MSG. Message object type is
* CPC_MSG_TYPE_CAN_FRAME or CPC_MSG_TYPE_RTR_FRAME or
Expand Down Expand Up @@ -278,6 +281,11 @@ static void ems_usb_read_interrupt_callback(struct urb *urb)
switch (urb->status) {
case 0:
dev->free_slots = dev->intr_in_buffer[1];
if(dev->free_slots > CPC_TX_QUEUE_TRIGGER_HIGH){
if (netif_queue_stopped(netdev)){
netif_wake_queue(netdev);
}
}
break;

case -ECONNRESET: /* unlink */
Expand Down Expand Up @@ -526,8 +534,6 @@ static void ems_usb_write_bulk_callback(struct urb *urb)
/* Release context */
context->echo_index = MAX_TX_URBS;

if (netif_queue_stopped(netdev))
netif_wake_queue(netdev);
}

/*
Expand Down Expand Up @@ -587,7 +593,7 @@ static int ems_usb_start(struct ems_usb *dev)
int err, i;

dev->intr_in_buffer[0] = 0;
dev->free_slots = 15; /* initial size */
dev->free_slots = 50; /* initial size */

for (i = 0; i < MAX_RX_URBS; i++) {
struct urb *urb = NULL;
Expand Down Expand Up @@ -835,7 +841,7 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne

/* Slow down tx path */
if (atomic_read(&dev->active_tx_urbs) >= MAX_TX_URBS ||
dev->free_slots < 5) {
dev->free_slots < CPC_TX_QUEUE_TRIGGER_LOW) {
netif_stop_queue(netdev);
}
}
Expand Down

0 comments on commit d856626

Please sign in to comment.