mtd: rawnand: gpmi: fix reference count leak in gpmi ops
authorZhang Qilong <zhangqilong3@huawei.com>
Sat, 7 Nov 2020 11:05:52 +0000 (19:05 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Dec 2020 10:53:49 +0000 (11:53 +0100)
commita50f5a6393e4de7627c9c7c3f50976bdef68b7f9
treed1fac573e0a041740d05759c525074bb7bbed764
parent0440989a08a5c71a7304da3dcb7d43de968cb721
mtd: rawnand: gpmi: fix reference count leak in gpmi ops

[ Upstream commit 1b391c7f2e863985668d705f525af3ceb55bc800 ]

pm_runtime_get_sync() will increment pm usage at first and it
will resume the device later. If runtime of the device has
error or device is in inaccessible state(or other error state),
resume operation will fail. If we do not call put operation to
decrease the reference, it will result in reference leak in
the two functions(gpmi_init and gpmi_nfc_exec_op). Moreover,
this device cannot enter the idle state and always stay busy or
other non-idle state later. So we fixed it through adding
pm_runtime_put_noidle.

Fixes: 5bc6bb603b4d0 ("mtd: rawnand: gpmi: Fix suspend/resume problem")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Acked-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20201107110552.1568742-1-zhangqilong3@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c