i2c: img-scb: fix reference leak when pm_runtime_get_sync fails
authorQinglang Miao <miaoqinglang@huawei.com>
Tue, 1 Dec 2020 09:31:39 +0000 (17:31 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 07:50:36 +0000 (09:50 +0200)
commite80ae8bde41266d3b8bf012460b6593851766006
tree48c3353119e379f4dbca9c8618c4633af065e5ae
parent30410519328c94367e561fd878e5f0d3a0303585
i2c: img-scb: fix reference leak when pm_runtime_get_sync fails

[ Upstream commit 223125e37af8a641ea4a09747a6a52172fc4b903 ]

The PM reference count is not expected to be incremented on
return in functions img_i2c_xfer and img_i2c_init.

However, pm_runtime_get_sync will increment the PM reference
count even failed. Forgetting to putting operation will result
in a reference leak here.

Replace it with pm_runtime_resume_and_get to keep usage
counter balanced.

Fixes: 93222bd9b966 ("i2c: img-scb: Add runtime PM")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i2c/busses/i2c-img-scb.c