Skip to content

Commit

Permalink
can: pcan_usb: fix wrong memcpy() bytes length
Browse files Browse the repository at this point in the history
Fix possibly wrong memcpy() bytes length since some CAN records received from
PCAN-USB could define a DLC field in range [9..15].
In that case, the real DLC value MUST be used to move forward the record pointer
but, only 8 bytes max. MUST be copied into the data field of the struct
can_frame object of the skb given to the network core.

Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stephane Grosjean authored and David S. Miller committed Aug 12, 2013
1 parent 29d7919 commit 3c322a5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/can/usb/peak_usb/pcan_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
if ((mc->ptr + rec_len) > mc->end)
goto decode_failed;

memcpy(cf->data, mc->ptr, rec_len);
memcpy(cf->data, mc->ptr, cf->can_dlc);
mc->ptr += rec_len;
}

Expand Down

0 comments on commit 3c322a5

Please sign in to comment.