can: kvaser_pciefd: kvaser_pciefd_open(): fix error handling
authorZhang Qilong <zhangqilong3@huawei.com>
Sat, 28 Nov 2020 13:39:22 +0000 (21:39 +0800)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 30 Nov 2020 11:43:55 +0000 (12:43 +0100)
If kvaser_pciefd_bus_on() failed, we should call close_candev() to avoid
reference leak.

Fixes: 26ad340e582d3 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Link: https://lore.kernel.org/r/20201128133922.3276973-3-zhangqilong3@huawei.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/kvaser_pciefd.c

index 72acd1b..43151dd 100644 (file)
@@ -692,8 +692,10 @@ static int kvaser_pciefd_open(struct net_device *netdev)
                return err;
 
        err = kvaser_pciefd_bus_on(can);
-       if (err)
+       if (err) {
+               close_candev(netdev);
                return err;
+       }
 
        return 0;
 }