]> git.karo-electronics.de Git - linux-beck.git/commitdiff
can: peak_usb: fix memset() usage
authorStephane Grosjean <s.grosjean@peak-system.com>
Fri, 28 Nov 2014 13:08:48 +0000 (14:08 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Sat, 6 Dec 2014 18:11:18 +0000 (19:11 +0100)
This patchs fixes a misplaced call to memset() that fills the request
buffer with 0. The problem was with sending PCAN_USBPRO_REQ_FCT
requests, the content set by the caller was thus lost.

With this patch, the memory area is zeroed only when requesting info
from the device.

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_pro.c

index 263dd921edc42342bba78ce9f2885862f0fc3087..f7f796a2c50bc036f7817b6fab070615e1795d37 100644 (file)
@@ -333,8 +333,6 @@ static int pcan_usb_pro_send_req(struct peak_usb_device *dev, int req_id,
        if (!(dev->state & PCAN_USB_STATE_CONNECTED))
                return 0;
 
-       memset(req_addr, '\0', req_size);
-
        req_type = USB_TYPE_VENDOR | USB_RECIP_OTHER;
 
        switch (req_id) {
@@ -345,6 +343,7 @@ static int pcan_usb_pro_send_req(struct peak_usb_device *dev, int req_id,
        default:
                p = usb_rcvctrlpipe(dev->udev, 0);
                req_type |= USB_DIR_IN;
+               memset(req_addr, '\0', req_size);
                break;
        }