]> git.baikalelectronics.ru Git - kernel.git/commit
can: c_can: c_can_power_up(): fix error handling
authorZhang Qilong <zhangqilong3@huawei.com>
Sat, 28 Nov 2020 13:39:21 +0000 (21:39 +0800)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 30 Nov 2020 11:43:55 +0000 (12:43 +0100)
commit7196a2f3d3791af208c27635c04d1cd3293e9fc2
tree401ac60b5f06beac0212f43b9a2abdc1e1e4bb7f
parent19f4a60eae1a79ad24e58b7c74006c1e35ca221b
can: c_can: c_can_power_up(): fix error handling

In the error handling in c_can_power_up(), there are two bugs:

1) c_can_pm_runtime_get_sync() will increase usage counter if device is not
   empty. Forgetting to call c_can_pm_runtime_put_sync() will result in a
   reference leak here.

2) c_can_reset_ram() operation will set start bit when enable is true. We
   should clear it in the error handling.

We fix it by adding c_can_pm_runtime_put_sync() for 1), and
c_can_reset_ram(enable is false) for 2) in the error handling.

Fixes: b8896cdefe224 ("can: c_can: Add d_can suspend resume support")
Fixes: 46f14a03f11a0 ("can: c_can: Add d_can raminit support")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Link: https://lore.kernel.org/r/20201128133922.3276973-2-zhangqilong3@huawei.com
[mkl: return "0" instead of "ret"]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/c_can/c_can.c