Skip to contentSkip to conversation

crypto: rockchip - Drop the runtime PM reference on DMA mapping errors

PATCH New Suyuan Wang 1 participant 1 message Nov 24

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: rockchip - Drop the runtime PM reference on DMA mapping errors

From: Suyuan Wang <[email protected]>

rk_cipher_run() takes a runtime PM reference with pm_runtime_resume_and_get() at the start of every request. The normal exit path drops it again at the theend label.

If dma_map_sg() fails, the function jumps to theend_sgs or theend_iv and returns the error without calling pm_runtime_put_autosuspend(). Each such request leaves one usage count behind, so the device can no longer runtime suspend.

Drop the reference on this error path too.

Found with a static analysis tool and checked by hand.

Fixes 9dcd71c863a6 ("crypto: rockchip - Add support for RK3399")

---
Compile tested on arm64 (W=1). I don't have the hardware.

---
 drivers/crypto/rockchip/rk3288_crypto_skcipher.c | 1 +
 1 file changed, 1 insertion(+)
drivers/crypto/rockchip/rk3288_crypto_skcipher.c +1 -0
index e80f9148c012..3f285175a194 100644
@@ -427,6 +427,7 @@ static int rk_cipher_run(struct crypto_engine *engine, void *async_req)
 		dma_unmap_sg(rkc->dev, sgd, 1, DMA_FROM_DEVICE);
 	}
 theend_iv:
+	pm_runtime_put_autosuspend(rkc->dev);
 	return err;
 }