wcn36xx_platform_get_resources() acquires two SMEM state handles. If acquiring the second handle fails, the first reference is leaked. Failures when looking up or mapping the MMIO resources also leave both state references held. Release the successfully acquired handles on these error paths. Found by code inspection. Fixes: f303a9311065 ("wcn36xx: Transition driver to SMD client") Signed-off-by: Wanhui Fu --- drivers/net/wireless/ath/wcn36xx/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index ad8a4bd910d2..fa3e86f442a6 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -1502,13 +1502,15 @@ static int wcn36xx_platform_get_resources(struct wcn36xx *wcn, "tx-rings-empty", &wcn->tx_rings_empty_state_bit); if (IS_ERR(wcn->tx_rings_empty_state)) { wcn36xx_err("failed to get tx-rings-empty state\n"); - return PTR_ERR(wcn->tx_rings_empty_state); + ret = PTR_ERR(wcn->tx_rings_empty_state); + goto put_enable_handle; } mmio_node = of_parse_phandle(pdev->dev.parent->of_node, "qcom,mmio", 0); if (!mmio_node) { wcn36xx_err("failed to acquire qcom,mmio reference\n"); - return -EINVAL; + ret = -EINVAL; + goto put_empty_handle; } wcn->is_pronto = !!of_device_is_compatible(mmio_node, "qcom,pronto"); @@ -1552,6 +1554,10 @@ unmap_ccu: iounmap(wcn->ccu_base); put_mmio_node: of_node_put(mmio_node); +put_empty_handle: + qcom_smem_state_put(wcn->tx_rings_empty_state); +put_enable_handle: + qcom_smem_state_put(wcn->tx_enable_state); return ret; } -- 2.25.1