Skip to contentSkip to conversation

pull-request: can 2022-01-09

PATCH Applied Marc Kleine-Budde 3 participants 8 messages Jan 9, 2022 – Jan 12, 2022

Subsystems (7)
lore
Share & tools
lore

Marc Kleine-Budde

author maintainer
#0 lore raw

cover pull-request: can 2022-01-09

Hello Jakub, hello David,

this is a pull request of 5 patches for net/master.

The first patch is by Johan Hovold and fixes a mem leak in the error path of the softing_cs driver.

The next patch is by me and fixes a set but not used variable warning in the softing driver.

Jiasheng Jiang's patch for the xilinx_can driver adds the missing error checking when getting the IRQ.

Lad Prabhakar contributes a patch for the rcar_canfd driver to fix a mem leak in the error path.

The last patch is by Brian Silverman and properly initializes the send USB messages to avoid spurious CAN error frames.

regards,
Marc

---

The following changes since commit 6dc9a23e29061e50c36523270de60039ccf536fa:

octeontx2-af: Fix interrupt name strings (2022-01-07 19:07:06 -0800)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-5.16-20220109

for you to fetch changes up to 89d58aebe14a365c25ba6645414afdbf4e41cea4:

can: gs_usb: gs_can_start_xmit(): zero-initialize hf->{flags,reserved} (2022-01-09 13:32:28 +0100)

----------------------------------------------------------------
linux-can-fixes-for-5.16-20220109

----------------------------------------------------------------
Brian Silverman (1):

      can: gs_usb: gs_can_start_xmit(): zero-initialize hf->{flags,reserved}

Jiasheng Jiang (1):
can: xilinx_can: xcan_probe(): check for error irq

Johan Hovold (1):
can: softing_cs: softingcs_probe(): fix memleak on registration failure

Lad Prabhakar (1):
can: rcar_canfd: rcar_canfd_channel_probe(): make sure we free CAN network device

Marc Kleine-Budde (1):
can: softing: softing_startstop(): fix set but not used variable warning

 drivers/net/can/rcar/rcar_canfd.c    |  5 ++---
 drivers/net/can/softing/softing_cs.c |  2 +-
 drivers/net/can/softing/softing_fw.c | 11 ++++++-----
 drivers/net/can/usb/gs_usb.c         |  2 ++
 drivers/net/can/xilinx_can.c         |  7 ++++++-
 5 files changed, 17 insertions(+), 10 deletions(-)
author maintainer
#1 lore raw

PATCH 1/5 can: softing_cs: softingcs_probe(): fix memleak on registration failure

From: Johan Hovold <[email protected]>

In case device registration fails during probe, the driver state and the embedded platform device structure needs to be freed using platform_device_put() to properly free all resources (e.g. the device name).

---
 drivers/net/can/softing/softing_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/softing/softing_cs.c +1 -1
index 2e93ee792373..e5c939b63fa6 100644
@@ -293,7 +293,7 @@ static int softingcs_probe(struct pcmcia_device *pcmcia)
 	return 0;
 
 platform_failed:
-	kfree(dev);
+	platform_device_put(pdev);
 mem_failed:
 pcmcia_bad:
 pcmcia_failed:

base-commit: 6dc9a23e29061e50c36523270de60039ccf536fa

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH net 1/5] can: softing_cs: softingcs_probe(): fix memleak on registration failure

This series was applied to netdev/net.git (master) by Marc Kleine-Budde <[email protected]>:

Hello:

This series was applied to netdev/net.git (master) by Marc Kleine-Budde <[email protected]>:

Quoted 8 lines · On Sun, 9 Jan 2022 14:40:36 +0100 you wrote:

From: Johan Hovold <[email protected]>

In case device registration fails during probe, the driver state and the embedded platform device structure needs to be freed using platform_device_put() to properly free all resources (e.g. the device name).

[...]

Here is the summary with links:
- [net,1/5] can: softing_cs: softingcs_probe(): fix memleak on registration failure

    https://git.kernel.org/netdev/net/c/ced4913efb0a
  - [net,2/5] can: softing: softing_startstop(): fix set but not used variable warning
    https://git.kernel.org/netdev/net/c/370d988cc529
  - [net,3/5] can: xilinx_can: xcan_probe(): check for error irq
    https://git.kernel.org/netdev/net/c/c6564c13dae2
  - [net,4/5] can: rcar_canfd: rcar_canfd_channel_probe(): make sure we free CAN network device
    https://git.kernel.org/netdev/net/c/72b1e360572f
  - [net,5/5] can: gs_usb: gs_can_start_xmit(): zero-initialize hf->{flags,reserved}
    https://git.kernel.org/netdev/net/c/89d58aebe14a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
author maintainer
#3 lore raw

PATCH 2/5 can: softing: softing_startstop(): fix set but not used variable warning

In reply to Marc Kleine-Budde

In the function softing_startstop() the variable error_reporting is assigned but not used. The code that uses this variable is commented out. Its stated that the functionality is not finally verified.

To fix the warning:

| drivers/net/can/softing/softing_fw.c:424:9: error: variable 'error_reporting' set but not used [-Werror,-Wunused-but-set-variable]

remove the comment, activate the code, but add a "0 &&" to the if expression and rely on the optimizer rather than the preprocessor to remove the code.

Fixes 03fd3cf5a179 ("can: add driver for Softing card")
Cc Kurt Van Dijck <[email protected]>
---
 drivers/net/can/softing/softing_fw.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/can/softing/softing_fw.c +6 -5
index 7e1536877993..32286f861a19 100644
@@ -565,18 +565,19 @@ int softing_startstop(struct net_device *dev, int up)
 		if (ret < 0)
 			goto failed;
 	}
-	/* enable_error_frame */
-	/*
+
+	/* enable_error_frame
+	 *
 	 * Error reporting is switched off at the moment since
 	 * the receiving of them is not yet 100% verified
 	 * This should be enabled sooner or later
-	 *
-	if (error_reporting) {
+	 */
+	if (0 && error_reporting) {
 		ret = softing_fct_cmd(card, 51, "enable_error_frame");
 		if (ret < 0)
 			goto failed;
 	}
-	*/
+
 	/* initialize interface */
 	iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 2]);
 	iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 4]);
Signature · 1 line
2.34.1
author maintainer
#4 lore raw

PATCH 3/5 can: xilinx_can: xcan_probe(): check for error irq

In reply to Marc Kleine-Budde

From: Jiasheng Jiang <[email protected]>

For the possible failure of the platform_get_irq(), the returned irq could be error number and will finally cause the failure of the request_irq().

Consider that platform_get_irq() can now in certain cases return -EPROBE_DEFER, and the consequences of letting request_irq() effectively convert that into -EINVAL, even at probe time rather than later on. So it might be better to check just now.

Fixes b1201e44f50b ("can: xilinx CAN controller support")
---
 drivers/net/can/xilinx_can.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/can/xilinx_can.c +6 -1
index e2b15d29d15e..af4a2adc8598 100644
@@ -1761,7 +1761,12 @@ static int xcan_probe(struct platform_device *pdev)
 	spin_lock_init(&priv->tx_lock);
 
 	/* Get IRQ for the device */
-	ndev->irq = platform_get_irq(pdev, 0);
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0)
+		goto err_free;
+
+	ndev->irq = ret;
+
 	ndev->flags |= IFF_ECHO;	/* We support local echo */
 
 	platform_set_drvdata(pdev, ndev);
Signature · 1 line
2.34.1
author maintainer
#5 lore raw

PATCH 4/5 can: rcar_canfd: rcar_canfd_channel_probe(): make sure we free CAN network device

In reply to Marc Kleine-Budde

From: Lad Prabhakar <[email protected]>

Make sure we free CAN network device in the error path. There are several jumps to fail label after allocating the CAN network device successfully. This patch places the free_candev() under fail label so that in failure path a jump to fail label frees the CAN network device.

---
 drivers/net/can/rcar/rcar_canfd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +2 -3
index ff9d0f5ae0dd..388521e70837 100644
@@ -1640,8 +1640,7 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
 	ndev = alloc_candev(sizeof(*priv), RCANFD_FIFO_DEPTH);
 	if (!ndev) {
 		dev_err(&pdev->dev, "alloc_candev() failed\n");
-		err = -ENOMEM;
-		goto fail;
+		return -ENOMEM;
 	}
 	priv = netdev_priv(ndev);
 
@@ -1735,8 +1734,8 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
 
 fail_candev:
 	netif_napi_del(&priv->napi);
-	free_candev(ndev);
 fail:
+	free_candev(ndev);
 	return err;
 }
 
Signature · 1 line
2.34.1
Reviewed-by on v1 4/5
#6 lore raw

Re: [PATCH net 4/5] can: rcar_canfd: rcar_canfd_channel_probe(): make sure we free CAN network device

Quoted 10 lines · Marc Kleine-Budde

From: Lad Prabhakar <[email protected]>

Make sure we free CAN network device in the error path. There are several jumps to fail label after allocating the CAN network device successfully. This patch places the free_candev() under fail label so that in failure path a jump to fail label frees the CAN network device.

Fixes 76e9353a80e9 ("can: rcar_canfd: Add support for RZ/G2L family")

Thank you!

Best regards,
Pavel

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
author maintainer
#7 lore raw

PATCH 5/5 can: gs_usb: gs_can_start_xmit(): zero-initialize hf->{flags,reserved}

In reply to Marc Kleine-Budde

From: Brian Silverman <[email protected]>

No information is deliberately sent in hf->flags in host -> device communications, but the open-source candleLight firmware echoes it back, which can result in the GS_CAN_FLAG_OVERFLOW flag being set and generating spurious ERRORFRAMEs.

While there also initialize the reserved member with 0.

Fixes d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices")
[mkl: initialize the reserved member, too]
---
 drivers/net/can/usb/gs_usb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/usb/gs_usb.c +2 -0
index d7ce2c5956f4..4d43aca2ff56 100644
@@ -508,6 +508,8 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
 
 	hf->echo_id = idx;
 	hf->channel = dev->channel;
+	hf->flags = 0;
+	hf->reserved = 0;
 
 	cf = (struct can_frame *)skb->data;
 
Signature · 1 line
2.34.1