Skip to content

Commit 72b1e36

Browse files
prabhakarladmarckleinebudde
authored andcommitted
can: rcar_canfd: rcar_canfd_channel_probe(): make sure we free CAN network device
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: 76e9353 ("can: rcar_canfd: Add support for RZ/G2L family") Link: https://lore.kernel.org/all/[email protected] Reported-by: Pavel Machek <[email protected]> Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Kieran Bingham <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent c6564c1 commit 72b1e36

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/net/can/rcar/rcar_canfd.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,8 +1640,7 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
16401640
ndev = alloc_candev(sizeof(*priv), RCANFD_FIFO_DEPTH);
16411641
if (!ndev) {
16421642
dev_err(&pdev->dev, "alloc_candev() failed\n");
1643-
err = -ENOMEM;
1644-
goto fail;
1643+
return -ENOMEM;
16451644
}
16461645
priv = netdev_priv(ndev);
16471646

@@ -1735,8 +1734,8 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
17351734

17361735
fail_candev:
17371736
netif_napi_del(&priv->napi);
1738-
free_candev(ndev);
17391737
fail:
1738+
free_candev(ndev);
17401739
return err;
17411740
}
17421741

0 commit comments

Comments
 (0)