]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Dec 2020 09:58:28 +0000 (10:58 +0100)
commitba3f951a6a0dd2c90f3d50276bf186822328f3dc
tree2fe12560f10cc79b1cc56a9f8ffa5d36caafeee9
parent50982ba118e4cd961ae1d0bfaa16a2b5032614f2
can: c_can: c_can_power_up(): fix error handling

[ Upstream commit 44cef0c0ffbd8d61143712ce874be68a273b7884 ]

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: 8212003260c60 ("can: c_can: Add d_can suspend resume support")
Fixes: 52cde85acc23f ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/can/c_can/c_can.c