spi: uniphier: fix reference count leak in uniphier_spi_probe()
authorXin Xiong <xiongx18@fudan.edu.cn>
Tue, 25 Jan 2022 10:12:15 +0000 (18:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Feb 2022 17:30:37 +0000 (18:30 +0100)
commite895e067d73e154b1ebc84a124e00831e311d9b0
treec215efe4a527ba45316a4f60326fc616ffa22bf2
parentec942d08e0706c882ff8d7c5b724c6744cd3fea8
spi: uniphier: fix reference count leak in uniphier_spi_probe()

commit 37c2c83ca4f1ef4b6908181ac98e18360af89b42 upstream.

The issue happens in several error paths in uniphier_spi_probe().
When either dma_get_slave_caps() or devm_spi_register_master() returns
an error code, the function forgets to decrease the refcount of both
`dma_rx` and `dma_tx` objects, which may lead to refcount leaks.

Fix it by decrementing the reference count of specific objects in
those error paths.

Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Fixes: 28d1dddc59f6 ("spi: uniphier: Add DMA transfer mode support")
Link: https://lore.kernel.org/r/20220125101214.35677-1-xiongx18@fudan.edu.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/spi/spi-uniphier.c