* [PATCH 1/6] can: dev: make can_change_state() robust to be called with cf == NULL
2017-06-09 12:55 pull-request: can 2017-06-09 Marc Kleine-Budde
@ 2017-06-09 12:55 ` Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 2/6] can: peak_canfd: fix uninitialized symbol warnings Marc Kleine-Budde
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2017-06-09 12:55 UTC (permalink / raw)
To: netdev; +Cc: davem, linux-can, kernel, Marc Kleine-Budde
In OOM situations where no skb can be allocated, can_change_state() may
be called with cf == NULL. As this function updates the state and error
statistics it's not an option to skip the call to can_change_state() in
OOM situations.
This patch makes can_change_state() robust, so that it can be called
with cf == NULL.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/dev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 611d16a7061d..ae4ed03dc642 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -391,6 +391,9 @@ void can_change_state(struct net_device *dev, struct can_frame *cf,
can_update_state_error_stats(dev, new_state);
priv->state = new_state;
+ if (!cf)
+ return;
+
if (unlikely(new_state == CAN_STATE_BUS_OFF)) {
cf->can_id |= CAN_ERR_BUSOFF;
return;
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] can: peak_canfd: fix uninitialized symbol warnings
2017-06-09 12:55 pull-request: can 2017-06-09 Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 1/6] can: dev: make can_change_state() robust to be called with cf == NULL Marc Kleine-Budde
@ 2017-06-09 12:55 ` Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 3/6] can: peak_usb: fix product-id endianness in error message Marc Kleine-Budde
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2017-06-09 12:55 UTC (permalink / raw)
To: netdev; +Cc: davem, linux-can, kernel, Stephane Grosjean, Marc Kleine-Budde
From: Stephane Grosjean <s.grosjean@peak-system.com>
This patch fixes two uninitialized symbol warnings in the new code adding
support of the PEAK-System PCAN-PCI Express FD boards, in the socket-CAN
network protocol family.
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/peak_canfd/peak_canfd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c
index 0d57be5ea97b..85268be0c913 100644
--- a/drivers/net/can/peak_canfd/peak_canfd.c
+++ b/drivers/net/can/peak_canfd/peak_canfd.c
@@ -489,7 +489,7 @@ int peak_canfd_handle_msgs_list(struct peak_canfd_priv *priv,
struct pucan_rx_msg *msg_list, int msg_count)
{
void *msg_ptr = msg_list;
- int i, msg_size;
+ int i, msg_size = 0;
for (i = 0; i < msg_count; i++) {
msg_size = peak_canfd_handle_msg(priv, msg_ptr);
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] can: peak_usb: fix product-id endianness in error message
2017-06-09 12:55 pull-request: can 2017-06-09 Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 1/6] can: dev: make can_change_state() robust to be called with cf == NULL Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 2/6] can: peak_canfd: fix uninitialized symbol warnings Marc Kleine-Budde
@ 2017-06-09 12:55 ` Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 4/6] can: gs_usb: fix memory leak in gs_cmd_reset() Marc Kleine-Budde
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2017-06-09 12:55 UTC (permalink / raw)
To: netdev; +Cc: davem, linux-can, kernel, Johan Hovold, Marc Kleine-Budde
From: Johan Hovold <johan@kernel.org>
Make sure to use the USB device product-id stored in host-byte order in
a probe error message.
Also remove a redundant reassignment of the local usb_dev variable which
had already been used to retrieve the product id.
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/usb/peak_usb/pcan_usb_core.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index 57913dbbae0a..1ca76e03e965 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -908,8 +908,6 @@ static int peak_usb_probe(struct usb_interface *intf,
const struct peak_usb_adapter *peak_usb_adapter = NULL;
int i, err = -ENOMEM;
- usb_dev = interface_to_usbdev(intf);
-
/* get corresponding PCAN-USB adapter */
for (i = 0; i < ARRAY_SIZE(peak_usb_adapters_list); i++)
if (peak_usb_adapters_list[i]->device_id == usb_id_product) {
@@ -920,7 +918,7 @@ static int peak_usb_probe(struct usb_interface *intf,
if (!peak_usb_adapter) {
/* should never come except device_id bad usage in this file */
pr_err("%s: didn't find device id. 0x%x in devices list\n",
- PCAN_USB_DRIVER_NAME, usb_dev->descriptor.idProduct);
+ PCAN_USB_DRIVER_NAME, usb_id_product);
return -ENODEV;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] can: gs_usb: fix memory leak in gs_cmd_reset()
2017-06-09 12:55 pull-request: can 2017-06-09 Marc Kleine-Budde
` (2 preceding siblings ...)
2017-06-09 12:55 ` [PATCH 3/6] can: peak_usb: fix product-id endianness in error message Marc Kleine-Budde
@ 2017-06-09 12:55 ` Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 5/6] can: af_can: namespace support: fix lockdep splat: properly initialize spin_lock Marc Kleine-Budde
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2017-06-09 12:55 UTC (permalink / raw)
To: netdev
Cc: davem, linux-can, kernel, Marc Kleine-Budde, linux-stable,
Maximilian Schneider
This patch adds the missing kfree() in gs_cmd_reset() to free the
memory that is not used anymore after usb_control_msg().
Cc: linux-stable <stable@vger.kernel.org>
Cc: Maximilian Schneider <max@schneidersoft.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/usb/gs_usb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index eecee7f8dfb7..afcc1312dbaf 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -265,6 +265,8 @@ static int gs_cmd_reset(struct gs_usb *gsusb, struct gs_can *gsdev)
sizeof(*dm),
1000);
+ kfree(dm);
+
return rc;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] can: af_can: namespace support: fix lockdep splat: properly initialize spin_lock
2017-06-09 12:55 pull-request: can 2017-06-09 Marc Kleine-Budde
` (3 preceding siblings ...)
2017-06-09 12:55 ` [PATCH 4/6] can: gs_usb: fix memory leak in gs_cmd_reset() Marc Kleine-Budde
@ 2017-06-09 12:55 ` Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 6/6] can: enable CAN FD for virtual CAN devices by default Marc Kleine-Budde
2017-06-09 19:42 ` pull-request: can 2017-06-09 David Miller
6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2017-06-09 12:55 UTC (permalink / raw)
To: netdev; +Cc: davem, linux-can, kernel, Marc Kleine-Budde, Mario Kicherer
This patch uses spin_lock_init() instead of __SPIN_LOCK_UNLOCKED() to
initialize the per namespace net->can.can_rcvlists_lock lock to fix this
lockdep warning:
| INFO: trying to register non-static key.
| the code is fine but needs lockdep annotation.
| turning off the locking correctness validator.
| CPU: 0 PID: 186 Comm: candump Not tainted 4.12.0-rc3+ #47
| Hardware name: Marvell Kirkwood (Flattened Device Tree)
| [<c0016644>] (unwind_backtrace) from [<c00139a8>] (show_stack+0x18/0x1c)
| [<c00139a8>] (show_stack) from [<c0058c8c>] (register_lock_class+0x1e4/0x55c)
| [<c0058c8c>] (register_lock_class) from [<c005bdfc>] (__lock_acquire+0x148/0x1990)
| [<c005bdfc>] (__lock_acquire) from [<c005deec>] (lock_acquire+0x174/0x210)
| [<c005deec>] (lock_acquire) from [<c04a6780>] (_raw_spin_lock+0x50/0x88)
| [<c04a6780>] (_raw_spin_lock) from [<bf02116c>] (can_rx_register+0x94/0x15c [can])
| [<bf02116c>] (can_rx_register [can]) from [<bf02a868>] (raw_enable_filters+0x60/0xc0 [can_raw])
| [<bf02a868>] (raw_enable_filters [can_raw]) from [<bf02ac14>] (raw_enable_allfilters+0x2c/0xa0 [can_raw])
| [<bf02ac14>] (raw_enable_allfilters [can_raw]) from [<bf02ad38>] (raw_bind+0xb0/0x250 [can_raw])
| [<bf02ad38>] (raw_bind [can_raw]) from [<c03b5fb8>] (SyS_bind+0x70/0xac)
| [<c03b5fb8>] (SyS_bind) from [<c000f8c0>] (ret_fast_syscall+0x0/0x1c)
Cc: Mario Kicherer <dev@kicherer.org>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
net/can/af_can.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/can/af_can.c b/net/can/af_can.c
index b6406fe33c76..88edac0f3e36 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -872,8 +872,7 @@ static int can_notifier(struct notifier_block *nb, unsigned long msg,
static int can_pernet_init(struct net *net)
{
- net->can.can_rcvlists_lock =
- __SPIN_LOCK_UNLOCKED(net->can.can_rcvlists_lock);
+ spin_lock_init(&net->can.can_rcvlists_lock);
net->can.can_rx_alldev_list =
kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL);
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] can: enable CAN FD for virtual CAN devices by default
2017-06-09 12:55 pull-request: can 2017-06-09 Marc Kleine-Budde
` (4 preceding siblings ...)
2017-06-09 12:55 ` [PATCH 5/6] can: af_can: namespace support: fix lockdep splat: properly initialize spin_lock Marc Kleine-Budde
@ 2017-06-09 12:55 ` Marc Kleine-Budde
2017-06-09 19:42 ` pull-request: can 2017-06-09 David Miller
6 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2017-06-09 12:55 UTC (permalink / raw)
To: netdev; +Cc: davem, linux-can, kernel, Oliver Hartkopp, Marc Kleine-Budde
From: Oliver Hartkopp <socketcan@hartkopp.net>
CAN FD capable CAN interfaces can handle (classic) CAN 2.0 frames too.
New users usually fail at their first attempt to explore CAN FD on
virtual CAN interfaces due to the current CAN_MTU default.
Set the MTU to CANFD_MTU by default to reduce this confusion.
If someone *really* needs a 'classic CAN'-only device this can be set
with the 'ip' tool with e.g. 'ip link set vcan0 mtu 16' as before.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/vcan.c | 2 +-
drivers/net/can/vxcan.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
index 0eda1b308583..a8cb33264ff1 100644
--- a/drivers/net/can/vcan.c
+++ b/drivers/net/can/vcan.c
@@ -152,7 +152,7 @@ static const struct net_device_ops vcan_netdev_ops = {
static void vcan_setup(struct net_device *dev)
{
dev->type = ARPHRD_CAN;
- dev->mtu = CAN_MTU;
+ dev->mtu = CANFD_MTU;
dev->hard_header_len = 0;
dev->addr_len = 0;
dev->tx_queue_len = 0;
diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c
index 30cf2368becf..cfe889e8f172 100644
--- a/drivers/net/can/vxcan.c
+++ b/drivers/net/can/vxcan.c
@@ -150,7 +150,7 @@ static const struct net_device_ops vxcan_netdev_ops = {
static void vxcan_setup(struct net_device *dev)
{
dev->type = ARPHRD_CAN;
- dev->mtu = CAN_MTU;
+ dev->mtu = CANFD_MTU;
dev->hard_header_len = 0;
dev->addr_len = 0;
dev->tx_queue_len = 0;
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: pull-request: can 2017-06-09
2017-06-09 12:55 pull-request: can 2017-06-09 Marc Kleine-Budde
` (5 preceding siblings ...)
2017-06-09 12:55 ` [PATCH 6/6] can: enable CAN FD for virtual CAN devices by default Marc Kleine-Budde
@ 2017-06-09 19:42 ` David Miller
6 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2017-06-09 19:42 UTC (permalink / raw)
To: mkl; +Cc: netdev, linux-can, kernel
From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Fri, 9 Jun 2017 14:55:07 +0200
> this is a pull request of 6 patches for net/master.
>
> There's a patch by Stephane Grosjean that fixes an uninitialized symbol warning
> in the peak_canfd driver. A patch by Johan Hovold to fix the product-id
> endianness in an error message in the the peak_usb driver. A patch by Oliver
> Hartkopp to enable CAN FD for virtual CAN devices by default. Three patches by
> me, one makes the helper function can_change_state() robust to be called with
> cf == NULL. The next patch fixes a memory leak in the gs_usb driver. And the
> last one fixes a lockdep splat by properly initialize the per-net
> can_rcvlists_lock spin_lock.
Pulled, thank you Marc.
^ permalink raw reply [flat|nested] 8+ messages in thread